Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

“lexical error (UTF-8 decoding error)” in WIndows 7 #912

Closed
bos opened this issue May 24, 2012 · 6 comments
Closed

“lexical error (UTF-8 decoding error)” in WIndows 7 #912

bos opened this issue May 24, 2012 · 6 comments

Comments

@bos
Copy link
Contributor

bos commented May 24, 2012

(Imported from Trac #922, reported by hamukazu on 2012-03-02)

Symptom

When I type

cabal install cabal

it fails with the following error:

Distribution\Compat\Exception.hs:0:4: lexical error (UTF-8 decoding error)

Environment

It happens with 64 bit version of Windows 7.

It came to occur after I failed to install HXT. (I am not sure it is related.)

Workaround

By setting

set LANG=C

in command line, cabal comes to work.

I regard this is just a workaround and this issue should be reported as a bug.

http://stackoverflow.com/questions/9371438/cabal-install-complains-built-in04-lexical-error-utf-8-decoding-error/9533205#9533205
http://trac.haskell.org/network/ticket/43

@bos
Copy link
Contributor Author

bos commented May 24, 2012

(Imported comment by @dcoutts on 2012-03-02)

Looks like cpp is outputting text that is not ASCII or UTF8. This then blows up because ghc expects .hs files to be UTF8.

Cabal can perhaps work around this cpp quirk by calling ghc/cpp with LANG=C.

The new program launching utils in Cabal should make it easier to set env vars like this.

It'd be useful if someone could confirm this hypothesis.

@bos
Copy link
Contributor Author

bos commented May 24, 2012

(Imported comment by @kosmikus on 2012-04-12)

Most likely will require a change in the Cabal lib.

@gregorycollins
Copy link
Member

@hamukazu is this still happening?

@hamukazu
Copy link

Recently I haven't used cabal on Windows, so I checked it just now.

I tested with latest version of Haskell Platform for Windows (2012.4.0.0) and MinGW (mingw-get-inst-20120426). The installation succeeded and UTF8 related error never reproduced even when I tried to install other packages after that.

I regard this is fixed.
Thanks.

@tibbe tibbe closed this as completed Jan 28, 2013
@batterseapower
Copy link
Contributor

This actually is a bug and is still happening. Duncan's diagnosis was correct. When you have configured Windows to use something other than English as the "locale for non Unicode programs" then mingw's CPP will output error messages and informational text in that locale. So for example, a C-preprocessed Haskell source file will have this at the top:

# 1 "libraries/filepath\\System\\FilePath.hs"
# 1 "<built-in>"
# 1 "<命令行>"
# 1 "libraries/filepath\\System\\FilePath.hs"

Where the text 命令行 (meaning 'command line interface', BTW) is actually encoded using the Chinese Windows code page rather than UTF-8.

Running the C-preprocessor with LANG=C fixes this because it causes gcc's tools to output messages in English.

@jneira
Copy link
Member

jneira commented Jul 10, 2022

Dont have access to a win 7 system to try to reproduce but it does not in windows 10
It seems to be a bug in ghc and its mingw c toolchain so newer ghc versions might not suffer from it.
Definitely not a cabal bug, so closing.

@jneira jneira closed this as completed Jul 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants