Stack: `stack script` ignores `nix: enable: true` in `~/.stack/config.yaml`

Created on 24 Dec 2017  Â·  3Comments  Â·  Source: commercialhaskell/stack

I want to make scripts that work on both nix and non-nix OS without changes

Steps to reproduce

example-script.hs

#!/usr/bin/env stack
{- stack
  script
  --resolver lts-9.18
-}

import           System.Environment    (getArgs)

main :: IO ()
main = do
  args <- getArgs
  print args

~/.stack/config.yaml

nix:
  enable: true
  packages:
    - libcxx
    - icu
    - gcc
    - ncurses
    - zlib
 ~/projects/nuuz/nuuz-chrome-extension/packages/metalib î‚° î‚  master î‚° update-index-js.hs index.js
Already downloaded.
Running /home/bjorn/.stack/programs/x86_64-linux/ghc-8.0.2.temp/ghc-8.0.2/configure --prefix=/home/bjorn/.stack/programs/x86_64-linux/ghc-8.0.2/ in directory /home/bjorn/.stack/programs/x86_64-linux/ghc-8.0.2.temp/ghc-8.0.2/ exited with ExitFailure 1

checking for path to top of build tree...
/home/bjorn/.stack/programs/x86_64-linux/ghc-8.0.2.temp/ghc-8.0.2/configure: utils/ghc-pwd/dist-install/build/tmp/ghc-pwd-bindist: /bin/bash: bad interpreter: No such file or directory
configure: error: cannot determine current directory


Error: Error encountered while configuring GHC with
         /home/bjorn/.stack/programs/x86_64-linux/ghc-8.0.2.temp/ghc-8.0.2/configure --prefix=/home/bjorn/.stack/programs/x86_64-linux/ghc-8.0.2/
         run in /home/bjorn/.stack/programs/x86_64-linux/ghc-8.0.2.temp/ghc-8.0.2/

The following directories may now contain files, but won't be used by stack:
  - /home/bjorn/.stack/programs/x86_64-linux/ghc-8.0.2.temp/
  - /home/bjorn/.stack/programs/x86_64-linux/ghc-8.0.2/

Configuring GHC ...% 

But I can resolve this issue by adding --nix option

#!/usr/bin/env stack
{- stack
  script
  --nix
  --resolver lts-9.18
-}

Expected

To work without --nix

Stack version

 ✘  ~  stack --version
Version 1.5.1 x86_64

Sorry, can't upgrade to latest stack-1.6.3

Method of installation

  • nix

P.S. without --nix, but with --verbose

script interpreter bug

Most helpful comment

I'm going to make this change

All 3 comments

Sorry for the delay in response. Was reminded of this ticket via #3887. Indeed, stack script does not read the global config. This is likely for reproducibility, but I'm thinking that it should read it. There is some further discussion in #3887

I'm running into this exact same problem. I'd like stack script to read the nix settings from ~/.stack/config.yaml, so I can run Haskell scripts on distributions with or without nix.

I'm going to make this change

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rrnewton picture rrnewton  Â·  4Comments

fizruk picture fizruk  Â·  3Comments

mgsloan picture mgsloan  Â·  3Comments

tinkyholloway picture tinkyholloway  Â·  4Comments

mgsloan picture mgsloan  Â·  3Comments