Skip to content

Fix #6861 Use nix-instantiate command, with failure exception#6945

Draft
mpilgrem wants to merge 1 commit into
masterfrom
fix6861
Draft

Fix #6861 Use nix-instantiate command, with failure exception#6945
mpilgrem wants to merge 1 commit into
masterfrom
fix6861

Conversation

@mpilgrem

@mpilgrem mpilgrem commented Jul 7, 2026

Copy link
Copy Markdown
Member

See:

Please also shortly describe how you tested your change. Bonus points for added tests!

If any users of Stack on NixOS or other users of Stack's Nix integration see this, I would appreciate any feedback on it.

@mpilgrem

mpilgrem commented Jul 8, 2026

Copy link
Copy Markdown
Member Author

I have converted to draft, as there is unexplained adverse changed behaviour in respect of locale when nix-shell is used with a store derivation of an expression rather than with the expression directly.

On my 'out of the box' Ubuntu (via WSL2), locale --all yields:

C
C.utf8
POSIX

With a one-package Stack project, with a library module Lib.hs

module Lib
  ( unicode
  ) where

{-# WARNING unicode "Warning emits unicode 😊" #-}
unicode :: IO ()
unicode = putStrLn "😊"

and executable myApp with Main.hs:

module Main
  ( main
  ) where

import           Lib ( unicode )

main :: IO ()
main = unicode

With 'official' Stack 3.11.1 binary (statically-linked):

stack build --nix --ghc-options=-Wno-extended-warnings and stack exec --nix -- myApp both work and stack build --nix --ghc-options=-Wextended-warnings also works.

With Stack-3.11.1 built from source (dynamically-linked):

stack build --nix --ghc-options=-Wextended-warnings (only) fails when GHC emits the unicode character (extract):

...
Preprocessing executable 'myApp' for myPackage-0.0.0...
Building executable 'myApp' for myPackage-0.0.0...
[1 of 1] Compiling Main
/home/mpilgrem/Code/Haskell/testNix/app/Main.hs:8:8: warning: [GHC-63394] [-Wdeprecations]
    In the use of `unicode' (imported from Lib):
    "Warning emits unicode
Error: [S-7282]
       Stack failed to execute the build plan.

       While executing the build plan, Stack encountered the error:

       <stderr>: commitAndReleaseBuffer: invalid argument (cannot encode character '\128522')

The problem is that locale en_US.UTF-8 is not available and the GHC runtime silently defaults to ASCII locale and encoding of stdout and stderr.

I understand the solution is to refer to a UTF-8 locale that is more likely to be available on the host, namely C.UTF-8.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant