Ticket #658 (new defect)

Opened 3 years ago

Last modified 15 months ago

cabal-install doesn't work with National account name.

Reported by: shelarcy Owned by:
Priority: normal Milestone: cabal-install-0.16
Component: cabal-install tool Version: 1.8.0.2
Severity: normal Keywords: UTF-8
Cc: Difficulty: unknown
GHC Version: 6.12.1 Platform: Windows

Description (last modified by shelarcy) (diff)

If Windows user uses national account name, cabal update is fail.

See:  http://www.sampou.org/cgi-bin/w3ml.cgi/haskell-jp/msg/545 (in Japanese)

I thought this problem is GHC 6.10.x and older's bug. So, I tested on Haskell Platform 2010.1.0.0 Windows installer RC3's cabal-install (version 0.8.1), and more recently version cabal-install 0.8.2. But this problem occur newer version (with my National account), too.

C:\Documents and Settings\崇裕>cabal update
Downloading the latest package list from hackage.haskell.org
cabal: invalid argument

And I tried to use cabal install command in package's directory. But cabal install is also fail.

C:\home\working\parsec-3.1.0>cabal install
cabal: C:\Documents and Settings\ユ\Application
Data\cabal\packages\hackage.haskell.org\00-index.tar: invalid argument

Above error message shows wrong path, but GHC 6.12.1's getTemporaryDirectory, getAppUserDataDirectory and getHomeDirectory show correct path.

Prelude System.Directory> getTemporaryDirectory
"C:\\DOCUME~1\\\23815\35029\\LOCALS~1\\Temp\\"

Prelude System.Directory> getAppUserDataDirectory "cabal"
"C:\\Documents and Settings\\\23815\35029\\Application Data\\cabal"

Prelude System.Directory> getHomeDirectory
"C:\\Documents and Settings\\\23815\35029"

So, I think cabal's function passes ascii version's API (*A) instead of wide charactor version's API (*W) internally.

I don't know where this problem come from, cabal-install or Cabal or GHC's library. So, I report this bug on Hackage's Bug Tracker.

Attachments

config Download (1.9 KB) - added by shelarcy 3 years ago.
cabal config file

Change History

  Changed 3 years ago by shelarcy

  • description modified (diff)

  Changed 3 years ago by shelarcy

  • description modified (diff)

follow-up: ↓ 4   Changed 3 years ago by duncan

Hmm, I expect the problem is that we store the repo cache directory in the cabal config file. Could you attach the config file please? cabal --help reports the location of the file.

Changed 3 years ago by shelarcy

cabal config file

in reply to: ↑ 3 ; follow-up: ↓ 5   Changed 3 years ago by shelarcy

Replying to duncan:

Hmm, I expect the problem is that we store the repo cache directory in the cabal config file. Could you attach the config file please? cabal --help reports the location of the file.

cabal --help also shows wrong location.

C:\Documents and Settings\崇裕>cabal --help
  (snip)

You can edit the cabal configuration file to set defaults:
  C:\Documents and Settings\ユ\Application Data\cabal\config

Anyway, config file is in correct place (C:\Documents and Settings\崇裕\Application Data\cabal) . So, I attached config file.

in reply to: ↑ 4 ; follow-ups: ↓ 6 ↓ 7   Changed 3 years ago by duncan

Replying to shelarcy:

Replying to duncan:

Hmm, I expect the problem is that we store the repo cache directory in the cabal config file. Could you attach the config file please? cabal --help reports the location of the file.

cabal --help also shows wrong location. {{{ C:\Documents and Settings\崇裕>cabal --help (snip) You can edit the cabal configuration file to set defaults: C:\Documents and Settings\ユ\Application Data\cabal\config }}}

That is surprising. We're just using getAppUserDataDirectory "cabal". What do you get when you run

ghc -e 'System.Directory.getAppUserDataDirectory "cabal" >>= putStrLn'

I would expect that the console encoding is such that it looks correct.

Anyway, config file is in correct place (C:\Documents and Settings\崇裕\Application Data\cabal) . So, I attached config file.

Thanks. The cases where we write it out not using Haskell String syntax are clearly going wrong. We read/write the config file using readFile and writeFile. In ghc-6.12 these should use the current code page on windows. Do we know what code page this user has?

Perhaps we should always write the config file in utf8 on windows. It's less clear on Unix since file paths are not necessarily unicode on unix.

in reply to: ↑ 5   Changed 3 years ago by shelarcy

Replying to duncan:

That is surprising. We're just using getAppUserDataDirectory "cabal". What do you get when you run {{{ ghc -e 'System.Directory.getAppUserDataDirectory "cabal" >>= putStrLn' }}} I would expect that the console encoding is such that it looks correct.

putStrLn prints wrong string. Because IO library doesn't support double-byte encodings (Chinese/Japanese/Korean) on Windows platform, now.

C:\Documents and Settings\崇裕>ghc -e "System.Directory.getAppUserDataDirectory \"cabal\" >>= putStrLn"
C:\Documents and Settings\ユ\Application Data\cabal

Anyway, config file is in correct place (C:\Documents and Settings\崇裕\Application Data\cabal) . So, I attached config file.

Thanks. The cases where we write it out not using Haskell String syntax are clearly going wrong. We read/write the config file using readFile and writeFile. In ghc-6.12 these should use the current code page on windows. Do we know what code page this user has?

Okay, I understand what causes this problem.

Because of IO library doesn't support double-byte encodings on Windows platform, readFile and writeFile doesn't work correctly on double-byte encoding Windows environment.

in reply to: ↑ 5   Changed 3 years ago by shelarcy

Replying to duncan:

Perhaps we should always write the config file in utf8 on windows. It's less clear on Unix since file paths are not necessarily unicode on unix.

Anther solution is to use show and read, before readFile and writeFile.

C:\Documents and Settings\崇裕>ghc -e "System.Directory.getAppUserDataDirectory \"cabal\" >>= putStrLn . show"
"C:\\Documents and Settings\\\23815\35029\\Application Data\\cabal"

It think that config file's "install-dirs user" prefix field and "install-dirs global" prefix field are escaped by using show function.

install-dirs user
  -- prefix: "C:\\Documents and Settings\\\23815\35029\\Application Data\\cabal"
 (snip)
install-dirs global
  -- prefix: "C:\\Program Files\\Haskell"

follow-up: ↓ 9   Changed 15 months ago by kosmikus

  • milestone set to cabal-install-0.16

Is this still an issue with current versions of cabal-install?

in reply to: ↑ 8   Changed 15 months ago by shelarcy

  • keywords UTF-8 added

Replying to kosmikus:

Is this still an issue with current versions of cabal-install?

Yes. This problem is not fixed in Haskell Platform's cabal-install 1.10.2.0, and GHC 7.4.1 with cabal-install HEAD.

C:\Users\崇裕>cabal --version
cabal-install version 0.10.2
using version 1.10.2.0 of the Cabal library

C:\Users\崇裕>cabal update
Config file path source is default config file.
Config file C:\Users\ユ\AppData\Roaming\cabal\config not found.
Writing default configuration to C:\Users\ユ\AppData\Roaming\cabal\config
Downloading the latest package list from hackage.haskell.org

C:\Users\崇裕>cabal install pqc
cabal:
C:\Users\ユ\AppData\Roaming\cabal\packages\hackage.haskell.org\00-index.tar:
invalid argument
C:\Users\崇裕>C:\TOOL\bin\new\cabal.exe --version
cabal-install version 0.13.3
using version 1.14.0 of the Cabal library

C:\Users\崇裕>C:\TOOL\bin\new\cabal.exe update
Config file path source is default config file.
Config file C:\Users\ユ\AppData\Roaming\cabal\config not found.
Writing default configuration to C:\Users\ユ\AppData\Roaming\cabal\config
Downloading the latest package list from hackage.haskell.org

C:\Users\崇裕>C:\TOOL\bin\new\cabal.exe install pqc
Warning: The package list for 'hackage.haskell.org' does not exist. Run 'cabal
update' to download it.
cabal.exe: There is no package named 'pqc'.
You may need to run 'cabal update' to get the latest list of available
packages.
Note: See TracTickets for help on using tickets.