commercialhaskell / stack

The Haskell Tool Stack
http://haskellstack.org
BSD 3-Clause "New" or "Revised" License
4k stars 843 forks source link

relative paths in "nix.path" are resolved from CWD instead of the project's root #3945

Open thufschmitt opened 6 years ago

thufschmitt commented 6 years ago

General summary/comments (optional)

When setting-up a stack project with Nix and nix.path refering to file with a relative path in stack.yaml, building from anywhere but the root of the project will cause the relative path to be resolved from the current directory instead of the root of the project (hence the file will probably not be found).

Steps to reproduce

stack new test && cd test
echo 'import (fetchTarball "https://github.com/nixos/nixpkgs/archive/1354099daf98b7a1f79e6c41ce6bfda5c40177ae.tar.gz")' > nixpkgs.nix
echo '\nnix:\n  enable: true\n  path: ["nixpkgs=./nixpkgs.nix"]' >> stack.yaml
unset NIX_PATH
stack build
(cd src && stack build)

Expected

Both stack build should success without warning

Actual

The first stack build builds fine, but the second one fails with

warning: Nix search path entry './nixpkgs.nix' does not exist, ignoring
error: file 'nixpkgs' was not found in the Nix search path (add it using $NIX_PATH or -I), at (string):1:14

Stack version

$ stack --version
Version 1.6.5 x86_64
Compiled with:
- Cabal-2.0.1.0
- Glob-0.9.1
- HUnit-1.6.0.0
- QuickCheck-2.10.1
- StateVar-1.1.0.4
- aeson-1.2.4.0
- aeson-compat-0.3.7.1
- annotated-wl-pprint-0.7.0
- ansi-terminal-0.7.1.1
- 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.1.1.1
- attoparsec-0.13.2.2
- attoparsec-iso8601-1.0.0.0
- auto-update-0.1.4
- base-4.10.1.0
- base-compat-0.9.3
- base-orphans-0.6
- base-prelude-1.2.0.1
- base16-bytestring-0.1.1.6
- base64-bytestring-1.0.0.1
- basement-0.0.4
- bifunctors-5.5.2
- binary-0.8.5.1
- bindings-uname-0.1
- bitarray-0.0.1.1
- blaze-builder-0.4.0.2
- blaze-html-0.9.0.1
- blaze-markup-0.8.2.0
- byteable-0.1.1
- bytestring-0.10.8.2
- call-stack-0.1.0
- case-insensitive-1.2.0.10
- cereal-0.5.5.0
- clock-0.7.2
- colour-2.3.4
- comonad-5.0.3
- conduit-1.2.13
- conduit-extra-1.2.3.2
- connection-0.2.8
- containers-0.5.10.2
- contravariant-1.4.1
- cookie-0.4.3
- cryptohash-0.11.9
- cryptohash-sha256-0.11.101.0
- cryptonite-0.24
- 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.0.2
- distributive-0.5.3
- dlist-0.8.0.4
- easy-file-0.2.1
- echo-0.1.3
- ed25519-0.0.5.0
- exceptions-0.8.3
- extra-1.6.4
- fail-4.9.0.0
- fast-logger-2.4.11
- file-embed-0.0.10.1
- filelock-0.1.1.2
- filepath-1.4.1.2
- foundation-0.0.17
- free-4.12.4
- fsnotify-0.2.1.1
- generic-deriving-1.12.1
- ghc-boot-th-8.2.2
- ghc-prim-0.5.1.1
- gitrev-1.3.1
- hackage-security-0.5.2.2
- hashable-1.2.6.1
- hastache-0.6.1
- hinotify-0.3.9
- hourglass-0.2.11
- hpack-0.21.2
- hpc-0.6.0.3
- hspec-2.4.4
- hspec-core-2.4.4
- hspec-discover-2.4.4
- hspec-expectations-0.8.2
- hspec-smallcheck-0.4.2
- http-api-data-0.3.7.2
- http-client-0.5.10
- http-client-tls-0.3.5.3
- http-conduit-2.2.4
- http-types-0.9.1
- ieee754-0.8.0
- integer-gmp-1.0.1.0
- integer-logarithms-1.0.2
- lifted-base-0.2.3.11
- logict-0.6.0.2
- memory-0.14.11
- microlens-0.4.8.3
- microlens-mtl-0.1.11.1
- microlens-th-0.4.1.3
- mime-types-0.1.0.7
- mintty-0.1.1
- mmorph-1.1.0
- monad-control-1.0.2.2
- monad-logger-0.3.28.1
- monad-loops-0.4.3
- mono-traversable-1.0.8.1
- mtl-2.2.1
- neat-interpolation-0.3.2.1
- network-2.6.3.3
- 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.1.0
- optparse-simple-0.1.0
- parsec-3.1.13.0
- path-0.6.1
- path-io-1.3.3
- path-pieces-0.2.1
- pem-0.2.2
- persistent-2.7.1
- persistent-sqlite-2.6.4
- persistent-template-2.5.3.1
- pid1-0.1.2.0
- prelude-extras-0.4.0.3
- pretty-1.1.3.3
- primitive-0.6.3.0
- process-1.6.1.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.1.11
- retry-0.7.6.0
- rts-1.0
- safe-0.3.15
- scientific-0.3.5.2
- semigroupoids-5.2.1
- semigroups-0.18.4
- setenv-0.1.1.3
- silently-1.2.5
- smallcheck-1.1.3.1
- socks-0.5.6
- split-0.2.3.3
- stm-2.4.5.0
- stm-chans-3.0.0.4
- store-0.4.3.2
- store-core-0.4.1
- streaming-commons-0.1.19
- syb-0.7
- tagged-0.8.5
- tar-0.5.0.3
- template-haskell-2.12.0.0
- temporary-1.2.1.1
- text-1.2.2.2
- text-metrics-0.3.0
- tf-random-0.5
- th-abstraction-0.2.6.0
- th-expand-syns-0.4.4.0
- th-lift-0.7.8
- th-lift-instances-0.1.11
- th-orphans-0.13.5
- th-reify-many-0.1.8
- th-utilities-0.2.0.1
- time-1.8.0.2
- time-locale-compat-0.1.1.3
- tls-1.4.0
- transformers-0.5.2.0
- transformers-base-0.4.4
- transformers-compat-0.5.1.4
- typed-process-0.2.1.0
- unicode-transforms-0.3.3
- unix-2.7.2.2
- unix-compat-0.5.0.1
- unix-time-0.3.7
- unliftio-0.2.4.0
- unliftio-core-0.1.1.0
- unordered-containers-0.2.8.0
- uri-bytestring-0.3.1.0
- uuid-types-1.0.3
- vector-0.12.0.1
- vector-algorithms-0.7.0.1
- void-0.7.2
- x509-1.7.2
- x509-store-1.6.5
- x509-system-1.6.6
- x509-validation-1.6.9
- yaml-0.8.28
- zip-archive-0.3.2.4
- zlib-0.6.1.2

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

Method of installation

Nix

/cc @mboes

thufschmitt commented 6 years ago

I'm willing to propose a fix for this, but I'm not sure what the best solution is. I see two ways to handle this: