Stack build fails with "startProcess: invalid argument (Bad file descriptor)"

I’m running NixOS 18.09. I have a Haskell project that I’m trying to build using Stack rather than Nix. (Later on I’ll probably convert it so it builds using Nix, but for now I want to use Stack.) This project builds without problems on Debian.

I start by cleaning out any old artifacts.

$ rm -rf .stack-work && stack clean
Note: Enabling Nix integration, as it is required under NixOS
Note: Enabling Nix integration, as it is required under NixOS
Cloning e6eb918b9df8b1549a34716def0cc1b2c06fbff4 from git@github.com:mhwombat/creatur-wains.git
Cloning into '/home/amy/néal/exp-dvector-ret-wains/.stack-work/downloaded/K-CoI8opox0Z'...
remote: Enumerating objects: 173, done.
remote: Counting objects: 100% (173/173), done.
remote: Compressing objects: 100% (110/110), done.
remote: Total 3316 (delta 80), reused 113 (delta 42), pack-reused 3143
Receiving objects: 100% (3316/3316), 702.29 KiB | 800.00 KiB/s, done.
Resolving deltas: 100% (1934/1934), done.
Cloning 16e92ea5c15017742e410e8f22e9f56853d8ea18 from https://github.com/mhwombat/creatur-wains-test-utils.git
Cloning into '/home/amy/néal/exp-dvector-ret-wains/.stack-work/downloaded/JhULpN7euz2w'...
remote: Enumerating objects: 30, done.
remote: Counting objects: 100% (30/30), done.
remote: Compressing objects: 100% (14/14), done.
remote: Total 95 (delta 10), reused 25 (delta 8), pack-reused 65
Unpacking objects: 100% (95/95), done.
Cloning cb1f7c5ace93856614735e5a82f01ea8885bdb66 from git@github.com:mhwombat/creatur-dvector-wains.git
Cloning into '/home/amy/néal/exp-dvector-ret-wains/.stack-work/downloaded/hBDSfnvP5q2A'...
remote: Enumerating objects: 6, done.
remote: Counting objects: 100% (6/6), done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 68 (delta 0), reused 3 (delta 0), pack-reused 62
Receiving objects: 100% (68/68), 20.61 KiB | 1.87 MiB/s, done.
Resolving deltas: 100% (19/19), done.
$ stack build
Note: Enabling Nix integration, as it is required under NixOS
Note: Enabling Nix integration, as it is required under NixOS
gray-extended-1.5.2: configure   
gray-extended-1.5.2: build       
gray-extended-1.5.2: copy/register
Progress 0/7: gray-extended-1.5.2
/home/amy/.stack/setup-exe-cache/x86_64-linux-nix/Cabal-simple_mPHDZzAJ_2.2.0.1_ghc-8.4.4: startProcess: invalid argument (Bad file descriptor)

It looks like it’s having trouble building gray-extended, which is another project of mine that it has to fetch from GitHub?

Here’s a verbose build, which seems to suggest an encoding issue? But the locale of my NixOS machine is en_IE.UTF-8, which is the same as the locale of the Debian machine that I developed everything on.

$ stack build --verbose
Version 1.7.1 x86_64
Compiled with:
- Cabal-2.2.0.1
- Glob-0.9.2
- HUnit-1.6.0.0
- QuickCheck-2.11.3
- StateVar-1.1.1.1
- aeson-1.3.1.1
- aeson-compat-0.3.8
- annotated-wl-pprint-0.7.0
- ansi-terminal-0.8.0.4
- ansi-wl-pprint-0.6.8.2
- array-0.5.2.0
- asn1-encoding-0.9.5
- asn1-parse-0.9.4
- asn1-types-0.3.2
- async-2.2.1
- attoparsec-0.13.2.2
- attoparsec-iso8601-1.0.0.0
- auto-update-0.1.4
- base-4.11.1.0
- base-compat-0.10.4
- base-orphans-0.7
- base-prelude-1.3
- base16-bytestring-0.1.1.6
- base64-bytestring-1.0.0.1
- basement-0.0.8
- bifunctors-5.5.3
- binary-0.8.5.1
- bindings-uname-0.1
- bitarray-0.0.1.1
- blaze-builder-0.4.1.0
- blaze-html-0.9.1.1
- blaze-markup-0.8.2.1
- byteable-0.1.1
- bytestring-0.10.8.2
- call-stack-0.1.0
- case-insensitive-1.2.0.11
- cereal-0.5.7.0
- clock-0.7.2
- colour-2.3.4
- comonad-5.0.4
- conduit-1.3.0.3
- conduit-extra-1.3.0
- connection-0.2.8
- constraints-0.10.1
- containers-0.5.11.0
- contravariant-1.4.1
- cookie-0.4.4
- cpphs-1.20.8
- cryptohash-0.11.9
- cryptohash-sha256-0.11.101.0
- cryptonite-0.25
- cryptonite-conduit-0.2.2
- data-default-class-0.1.2.0
- deepseq-1.4.3.0
- digest-0.0.1.2
- directory-1.3.1.5
- distributive-0.5.3
- dlist-0.8.0.4
- easy-file-0.2.2
- echo-0.1.3
- ed25519-0.0.5.0
- either-5.0.1
- enclosed-exceptions-1.0.3
- exceptions-0.10.0
- extra-1.6.9
- fast-logger-2.4.11
- file-embed-0.0.10.1
- filelock-0.1.1.2
- filepath-1.4.2
- foundation-0.0.21
- free-5.0.2
- fsnotify-0.3.0.1
- generic-deriving-1.12.2
- ghc-boot-th-8.4.3
- ghc-prim-0.5.2.0
- gitrev-1.3.1
- hackage-security-0.5.3.0
- hashable-1.2.7.0
- haskell-src-exts-1.20.2
- haskell-src-meta-0.8.0.3
- hinotify-0.3.10
- hourglass-0.2.12
- hpack-0.28.2
- hpc-0.6.0.3
- hspec-2.5.5
- hspec-core-2.5.5
- hspec-discover-2.5.5
- hspec-expectations-0.8.2
- hspec-smallcheck-0.5.2
- http-api-data-0.3.8.1
- http-client-0.5.13.1
- http-client-tls-0.3.5.3
- http-conduit-2.3.2
- http-types-0.12.1
- integer-gmp-1.0.2.0
- integer-logarithms-1.0.2.1
- lifted-async-0.10.0.2
- lifted-base-0.2.3.12
- logict-0.6.0.2
- megaparsec-6.5.0
- memory-0.14.16
- microlens-0.4.9.1
- microlens-th-0.4.2.2
- mime-types-0.1.0.8
- mintty-0.1.2
- monad-control-1.0.2.3
- monad-logger-0.3.29
- monad-loops-0.4.3
- mono-traversable-1.0.9.0
- mtl-2.2.2
- mustache-2.3.0
- neat-interpolation-0.3.2.2
- network-2.6.3.6
- network-uri-2.6.1.0
- old-locale-1.0.0.7
- old-time-1.1.0.3
- open-browser-0.2.1.0
- optparse-applicative-0.14.2.0
- optparse-simple-0.1.0
- parsec-3.1.13.0
- parser-combinators-1.0.0
- path-0.6.1
- path-io-1.3.3
- path-pieces-0.2.1
- pem-0.2.4
- persistent-2.8.2
- persistent-sqlite-2.8.2
- persistent-template-2.5.4
- polyparse-1.12
- pretty-1.1.3.6
- primitive-0.6.3.0
- process-1.6.3.0
- profunctors-5.2.2
- project-template-0.2.0.1
- quickcheck-io-0.2.0
- random-1.1
- regex-applicative-0.3.3
- regex-applicative-text-0.1.0.1
- resource-pool-0.2.3.2
- resourcet-1.2.1
- retry-0.7.7.0
- rio-0.1.5.0
- rts-1.0
- safe-0.3.17
- scientific-0.3.6.2
- semigroupoids-5.2.2
- semigroups-0.18.5
- setenv-0.1.1.3
- shelly-1.8.1
- silently-1.2.5
- smallcheck-1.1.5
- socks-0.5.6
- split-0.2.3.3
- stm-2.4.5.0
- stm-chans-3.0.0.4
- store-0.5.0
- store-core-0.4.4
- streaming-commons-0.2.1.0
- syb-0.7
- system-fileio-0.3.16.3
- system-filepath-0.4.14
- tagged-0.8.5
- tar-0.5.1.0
- template-haskell-2.13.0.0
- temporary-1.3
- text-1.2.3.0
- text-metrics-0.3.0
- tf-random-0.5
- th-abstraction-0.2.8.0
- th-expand-syns-0.4.4.0
- th-lift-0.7.11
- th-lift-instances-0.1.11
- th-orphans-0.13.6
- th-reify-many-0.1.8
- th-utilities-0.2.0.1
- time-1.8.0.2
- time-locale-compat-0.1.1.5
- tls-1.4.1
- transformers-0.5.5.0
- transformers-base-0.4.5.2
- transformers-compat-0.6.2
- typed-process-0.2.3.0
- unicode-transforms-0.3.4
- unix-2.7.2.2
- unix-compat-0.5.1
- unix-time-0.3.8
- unliftio-0.2.7.1
- unliftio-core-0.1.2.0
- unordered-containers-0.2.9.0
- uri-bytestring-0.3.2.0
- uuid-types-1.0.3
- vector-0.12.0.1
- vector-algorithms-0.7.0.4
- void-0.7.2
- x509-1.7.3
- x509-store-1.6.6
- x509-system-1.6.6
- x509-validation-1.6.10
- yaml-0.8.32
- zip-archive-0.3.3
- zlib-0.6.2

Warning: this is an unsupported build that may use different versions of
dependencies and GHC than the officially released binaries, and therefore may
not behave identically.  If you encounter problems, please try the latest
official build by running 'stack upgrade --force-download'.

2018-12-12 17:04:38.234304: [debug] Checking for project config at: /home/amy/néal/exp-dvector-ret-wains/stack.yaml
2018-12-12 17:04:38.234597: [debug] Loading project config file stack.yaml
2018-12-12 17:04:38.236195: [info] Note: Enabling Nix integration, as it is required under NixOS
2018-12-12 17:04:38.237038: [debug] Decoding build plan from: /home/amy/.stack/build-plan/lts-12.16.yaml
2018-12-12 17:04:38.237135: [debug] Trying to decode /home/amy/.stack/build-plan-cache/lts-12.16.cache
2018-12-12 17:04:38.241630: [debug] Success decoding /home/amy/.stack/build-plan-cache/lts-12.16.cache
2018-12-12 17:04:38.241807: [debug] PATH is: Just "/home/amy/bin:/home/amy/.local/bin:/home/amy/.cabal/bin:/home/amy/bin:/run/wrappers/bin:/home/amy/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin:/etc/profiles/per-user/amy/bin"
2018-12-12 17:04:38.241898: [debug] Using a nix-shell environment with nix packages: haskell.compiler.ghc844, git, gcc, gmp
2018-12-12 17:04:38.242854: [debug] Run process: /run/current-system/sw/bin/nix-shell --pure -E "with (import <nixpkgs> {}); let inputs = [haskell.compiler.ghc844 git gcc gmp]; libPath = lib.makeLibraryPath inputs; stackExtraArgs = lib.concatMap (pkg: [ ''--extra-lib-dirs=${lib.getLib pkg}/lib''   ''--extra-include-dirs=${lib.getDev pkg}/include'' ]) inputs; in runCommand ''myEnv'' { buildInputs = lib.optional stdenv.isLinux glibcLocales ++ inputs; STACK_PLATFORM_VARIANT=''nix''; STACK_IN_NIX_SHELL=1; LD_LIBRARY_PATH = libPath;STACK_IN_NIX_EXTRA_ARGS = stackExtraArgs; } \"\"" --run "'/nix/store/qydqgyjd3ca82d8cb9mjpif60bahjsnc-stack-1.7.1/bin/stack' $STACK_IN_NIX_EXTRA_ARGS '--internal-re-exec-version=1.7.1' 'build' '--verbose'"
Version 1.7.1 x86_64
Compiled with:
- Cabal-2.2.0.1
- Glob-0.9.2
- HUnit-1.6.0.0
- QuickCheck-2.11.3
- StateVar-1.1.1.1
- aeson-1.3.1.1
- aeson-compat-0.3.8
- annotated-wl-pprint-0.7.0
- ansi-terminal-0.8.0.4
- ansi-wl-pprint-0.6.8.2
- array-0.5.2.0
- asn1-encoding-0.9.5
- asn1-parse-0.9.4
- asn1-types-0.3.2
- async-2.2.1
- attoparsec-0.13.2.2
- attoparsec-iso8601-1.0.0.0
- auto-update-0.1.4
- base-4.11.1.0
- base-compat-0.10.4
- base-orphans-0.7
- base-prelude-1.3
- base16-bytestring-0.1.1.6
- base64-bytestring-1.0.0.1
- basement-0.0.8
- bifunctors-5.5.3
- binary-0.8.5.1
- bindings-uname-0.1
- bitarray-0.0.1.1
- blaze-builder-0.4.1.0
- blaze-html-0.9.1.1
- blaze-markup-0.8.2.1
- byteable-0.1.1
- bytestring-0.10.8.2
- call-stack-0.1.0
- case-insensitive-1.2.0.11
- cereal-0.5.7.0
- clock-0.7.2
- colour-2.3.4
- comonad-5.0.4
- conduit-1.3.0.3
- conduit-extra-1.3.0
- connection-0.2.8
- constraints-0.10.1
- containers-0.5.11.0
- contravariant-1.4.1
- cookie-0.4.4
- cpphs-1.20.8
- cryptohash-0.11.9
- cryptohash-sha256-0.11.101.0
- cryptonite-0.25
- cryptonite-conduit-0.2.2
- data-default-class-0.1.2.0
- deepseq-1.4.3.0
- digest-0.0.1.2
- directory-1.3.1.5
- distributive-0.5.3
- dlist-0.8.0.4
- easy-file-0.2.2
- echo-0.1.3
- ed25519-0.0.5.0
- either-5.0.1
- enclosed-exceptions-1.0.3
- exceptions-0.10.0
- extra-1.6.9
- fast-logger-2.4.11
- file-embed-0.0.10.1
- filelock-0.1.1.2
- filepath-1.4.2
- foundation-0.0.21
- free-5.0.2
- fsnotify-0.3.0.1
- generic-deriving-1.12.2
- ghc-boot-th-8.4.3
- ghc-prim-0.5.2.0
- gitrev-1.3.1
- hackage-security-0.5.3.0
- hashable-1.2.7.0
- haskell-src-exts-1.20.2
- haskell-src-meta-0.8.0.3
- hinotify-0.3.10
- hourglass-0.2.12
- hpack-0.28.2
- hpc-0.6.0.3
- hspec-2.5.5
- hspec-core-2.5.5
- hspec-discover-2.5.5
- hspec-expectations-0.8.2
- hspec-smallcheck-0.5.2
- http-api-data-0.3.8.1
- http-client-0.5.13.1
- http-client-tls-0.3.5.3
- http-conduit-2.3.2
- http-types-0.12.1
- integer-gmp-1.0.2.0
- integer-logarithms-1.0.2.1
- lifted-async-0.10.0.2
- lifted-base-0.2.3.12
- logict-0.6.0.2
- megaparsec-6.5.0
- memory-0.14.16
- microlens-0.4.9.1
- microlens-th-0.4.2.2
- mime-types-0.1.0.8
- mintty-0.1.2
- monad-control-1.0.2.3
- monad-logger-0.3.29
- monad-loops-0.4.3
- mono-traversable-1.0.9.0
- mtl-2.2.2
- mustache-2.3.0
- neat-interpolation-0.3.2.2
- network-2.6.3.6
- network-uri-2.6.1.0
- old-locale-1.0.0.7
- old-time-1.1.0.3
- open-browser-0.2.1.0
- optparse-applicative-0.14.2.0
- optparse-simple-0.1.0
- parsec-3.1.13.0
- parser-combinators-1.0.0
- path-0.6.1
- path-io-1.3.3
- path-pieces-0.2.1
- pem-0.2.4
- persistent-2.8.2
- persistent-sqlite-2.8.2
- persistent-template-2.5.4
- polyparse-1.12
- pretty-1.1.3.6
- primitive-0.6.3.0
- process-1.6.3.0
- profunctors-5.2.2
- project-template-0.2.0.1
- quickcheck-io-0.2.0
- random-1.1
- regex-applicative-0.3.3
- regex-applicative-text-0.1.0.1
- resource-pool-0.2.3.2
- resourcet-1.2.1
- retry-0.7.7.0
- rio-0.1.5.0
- rts-1.0
- safe-0.3.17
- scientific-0.3.6.2
- semigroupoids-5.2.2
- semigroups-0.18.5
- setenv-0.1.1.3
- shelly-1.8.1
- silently-1.2.5
- smallcheck-1.1.5
- socks-0.5.6
- split-0.2.3.3
- stm-2.4.5.0
- stm-chans-3.0.0.4
- store-0.5.0
- store-core-0.4.4
- streaming-commons-0.2.1.0
- syb-0.7
- system-fileio-0.3.16.3
- system-filepath-0.4.14
- tagged-0.8.5
- tar-0.5.1.0
- template-haskell-2.13.0.0
- temporary-1.3
- text-1.2.3.0
- text-metrics-0.3.0
- tf-random-0.5
- th-abstraction-0.2.8.0
- th-expand-syns-0.4.4.0
- th-lift-0.7.11
- th-lift-instances-0.1.11
- th-orphans-0.13.6
- th-reify-many-0.1.8
- th-utilities-0.2.0.1
- time-1.8.0.2
- time-locale-compat-0.1.1.5
- tls-1.4.1
- transformers-0.5.5.0
- transformers-base-0.4.5.2
- transformers-compat-0.6.2
- typed-process-0.2.3.0
- unicode-transforms-0.3.4
- unix-2.7.2.2
- unix-compat-0.5.1
- unix-time-0.3.8
- unliftio-0.2.7.1
- unliftio-core-0.1.2.0
- unordered-containers-0.2.9.0
- uri-bytestring-0.3.2.0
- uuid-types-1.0.3
- vector-0.12.0.1
- vector-algorithms-0.7.0.4
- void-0.7.2
- x509-1.7.3
- x509-store-1.6.6
- x509-system-1.6.6
- x509-validation-1.6.10
- yaml-0.8.32
- zip-archive-0.3.3
- zlib-0.6.2

Warning: this is an unsupported build that may use different versions of
dependencies and GHC than the officially released binaries, and therefore may
not behave identically.  If you encounter problems, please try the latest
official build by running 'stack upgrade --force-download'.

mkLogOptions: invalid UTF8 sequence: (Cannot decode byte '\xed': Data.Text.Internal.Encoding.decodeUtf8: Invalid UTF-8 stream,"\ESC[90m2018-12-12 17:04:39.804145: \ESC[32m[debug] \ESC[0mChecking for project config at: /home/amy/n\237\179\131\237\178\169al/exp-dvector-ret-wains/stack.yaml\ESC[0m\n")
CallStack (from HasCallStack):
  error, called at src/RIO/Prelude/Logger.hs:319:25 in rio-0.1.5.0-ANCqpbdjBtsBeyihddt2kk:RIO.Prelude.Logger

I did notice this message…

Warning: this is an unsupported build that may use different versions of
dependencies and GHC than the officially released binaries, and therefore may
not behave identically.  If you encounter problems, please try the latest
official build by running 'stack upgrade --force-download'.

… so I did a full system upgrade in hopes that would upgrade stack. Now I’m getting an error about something in gray-extended that stack didn’t used to care about, but apparently the new version does. Anyway, I believe I can fix this now.

I’ll leave the previous post up in case someone else gets that weird error message.