Skip to content
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 script` ignores `nix: enable: true` in `~/.stack/config.yaml` #3705

Closed
srghma opened this issue Dec 24, 2017 · 3 comments

Comments

Projects
None yet
5 participants
@srghma
Copy link

commented Dec 24, 2017

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

@mgsloan

This comment has been minimized.

Copy link
Collaborator

commented Feb 25, 2018

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

@cdepillabout

This comment has been minimized.

Copy link
Member

commented Mar 4, 2018

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.

@snoyberg

This comment has been minimized.

Copy link
Contributor

commented Apr 1, 2019

I'm going to make this change

snoyberg added a commit that referenced this issue Apr 5, 2019

Rename NoConfig to NoProject
This also changes the behavior: we _do_ load up the user config file,
just no project config file.

* Fixes #3705
* Fixes #3887

snoyberg added a commit that referenced this issue Apr 5, 2019

Rename NoConfig to NoProject
This also changes the behavior: we _do_ load up the user config file,
just no project config file.

* Fixes #3705
* Fixes #3887
* Fixes #4699
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.