-
Notifications
You must be signed in to change notification settings - Fork 841
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
Stack MUST ignore and override user locale variables #4859
Comments
Thanks @fare for raising this issue! As I understand, the specific bug report is that |
The immediate breakage was from Even if |
For reference, my workaround was to use a {ghc}:
with (import <nixpkgs> {});
haskell.lib.buildStackProject {
inherit ghc;
name = "alacrity";
buildInputs = [ z3 ];
shellHook = lib.optionalString (glibcLocales != null) ''
export LOCALE_ARCHIVE="${glibcLocales}/lib/locale/locale-archive"
'' + ''
export LC_ALL=C.UTF-8
'';
} Of course, the above only works when using Nix. A more general solution should work even without Nix, and should probably use |
Indeed, |
Also, the nix guys think everything is alright with their tool. It's on stack to make utf-8 available. NixOS/nixpkgs#63014 |
I agree that this locale-sensitive behavior for file reading is incorrect (you referenced my blog post on it), but disagree with this being something Stack should try to modify. It can lead to even more confusing behavior if Stack is circumventing the natural behavior of the programs it is calling out to. Closing as wontfix (though the specific case for Nix does appear to already be addressed). |
General summary/comments (optional)
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 stack. 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 suitableshell.nix
forstack.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 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 stack, as I suspect no one useslatin1
,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 cabal:
NixOS/nixpkgs#63014
haskell/cabal#6076
Steps to reproduce
Expected
It should compile successfully, as if I had built with
LC_ALL=en_US.UTF-8
Actual
Stack version
Method of installation
The text was updated successfully, but these errors were encountered: