-
Notifications
You must be signed in to change notification settings - Fork 696
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
Cabal MUST ignore and override user locale variables #6076
Comments
Makes sense, yes. |
This particular Unicode issue is with
|
It's a problem with anything that is built through Cabal, not just with happy. |
Faced exact same error message when building my website in Docker container (Debian based).
Solved issue by setting locale:
Upgrading stack from Hope this will help somebody. |
To what User have to configure their systems. In fact, just today we checked Haskell Report (and GHC manual), and there isn't any specific wording that Haskell source files have to be in some specific encoding! |
The only locale both portable and useful is
|
It's still a bug in
Happy is a compiler. Make We won't workaround bugs which are easily fixable in the tools themselves. Adding workarounds is not sustainable. Yes it might mean that you need to fix almost every tool, but that's the right approach. Or just set |
While building source code, compilers and build tools should ALWAYS process each and every source file using the encoding with which the file was written by its authors and released by its maintainers, and NEVER process any of those files with the locale inherited from the end-user when they introduce any discrepancy whatsoever. The proper thing to do is thus to NEVER, EVER heed the user-inherited locale variables
LANG
andLC_*
— the very idea flies in the face of the determinism aimed at by cabal. If some interactive flag allows to explicitly inherit those variables, any discrepancy in encoding should still lead to a prominent warning unless explicitly hushed.The only imaginable defaults that make any sense for the locale are
POSIX
anden_US.UTF-8
. ThePOSIX
default would impose needless pain for no gain whatsoever in a day where UTF-8 is now a widely accepted and supported standard, so the only sensible and useful default isen_US.UTF-8
(I would have proposed the more neutralC.UTF-8
but it doesn't work on Darwin).I was faced with this bug while building with stack a Haskell program that depended on language-javascript, and had a painful debug session until I found how to configure a suitable shell.nix for stack.yaml. Drilling to root causes led me to find that it's a fundamental bug in all of Nix, Cabal, Hackage and Stack. Remarkably, I fixed the very same issue in Common Lisp, where the build system ASDF now assumes that all source code is UTF-8 by default, unless overridden by the library maintainers, and never ever heeding user locale. The switch was slightly painful, hounding maintainers of tens of libraries and actually pulling the switch only a year after warning everyone. The switch should be simpler for Cabal, as I suspect no one uses
latin1
,latin2
,euc-jp
orkoi8-r
anymore in any Haskell package.See also:
https://www.snoyman.com/blog/2016/12/beware-of-readfile
agda/agda#2922
input-output-hk/cardano-sl@ed8c892
NB: I filed the same issue against nixpkgs and stack:
NixOS/nixpkgs#63014
commercialhaskell/stack#4859
Steps to reproduce
Expected
It should compile successfully, as if I had built with
LC_ALL=en_US.UTF-8
Actual
Using Cabal 2.4.0.1.
The text was updated successfully, but these errors were encountered: