commercialhaskell / stack

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

stack build - Executable named nix-shell not found on path #5011

Open freeman42x opened 5 years ago

freeman42x commented 5 years ago

Steps to reproduce

Expected

Build to succeed.

Actual

What actually happened.

stack build --verbose
2.1.3.1 x86_64 hpack-0.31.2
2019-08-19 21:29:01.125182: [debug] Checking for project config at: /home/neo/Projects/fairy-tale-artificial-general-intelligence-solutions/Sources/Razvan Flavius Panda/Haskell/artificial-general-intelligence/stack.yaml
2019-08-19 21:29:01.125600: [debug] Loading project config file stack.yaml
2019-08-19 21:29:01.139628: [debug] SELECT COUNT(*) FROM "last_performed" WHERE ("action"=?) AND ("timestamp">=?); [PersistInt64 1,PersistUTCTime 2019-08-18 20:29:01.139559845 UTC]
2019-08-19 21:29:01.140412: [debug] Using package location completions from a lock file
2019-08-19 21:29:01.354730: [debug] Running hpack on /home/neo/Projects/fairy-tale-artificial-general-intelligence-solutions/Sources/Razvan Flavius Panda/Haskell/artificial-general-intelligence/package.yaml
2019-08-19 21:29:01.359823: [debug] hpack output unchanged in /home/neo/Projects/fairy-tale-artificial-general-intelligence-solutions/Sources/Razvan Flavius Panda/Haskell/artificial-general-intelligence/artificial-general-intelligence.cabal
2019-08-19 21:29:01.363425: [debug] PATH is: Just "/nix/store/gvshp9yvc6gql09r3cyryj2zgsnfk6br-ghc-8.6.4/bin:/nix/store/ghzg4kg0sjif58smj2lfm2bdvjwim85y-gcc-wrapper-7.4.0/bin:/nix/store/d4n93jn9fdq8fkmkm1q8f32lfagvibjk-gcc-7.4.0/bin:/nix/store/f5wl80zkrd3fc1jxsljmnpn7y02lz6v1-glibc-2.27-bin/bin:/nix/store/d9s1kq1bnwqgxwcvv4zrc36ysnxg8gv7-coreutils-8.30/bin:/nix/store/rbpyfy6413aqpik9aj6p3a2syd1mda68-binutils-wrapper-2.31.1/bin:/nix/store/0y7jmqnj48ikjh37n3dl9kqw9hnn68nq-binutils-2.31.1/bin:/nix/store/f5wl80zkrd3fc1jxsljmnpn7y02lz6v1-glibc-2.27-bin/bin:/nix/store/d9s1kq1bnwqgxwcvv4zrc36ysnxg8gv7-coreutils-8.30/bin:/nix/store/gis2bz09gr9sgv1xiimyszcgv2grknpj-ncurses-6.1-20190112/bin:/nix/store/gvshp9yvc6gql09r3cyryj2zgsnfk6br-ghc-8.6.4/bin:/nix/store/ghzg4kg0sjif58smj2lfm2bdvjwim85y-gcc-wrapper-7.4.0/bin:/nix/store/d4n93jn9fdq8fkmkm1q8f32lfagvibjk-gcc-7.4.0/bin:/nix/store/f5wl80zkrd3fc1jxsljmnpn7y02lz6v1-glibc-2.27-bin/bin:/nix/store/d9s1kq1bnwqgxwcvv4zrc36ysnxg8gv7-coreutils-8.30/bin:/nix/store/rbpyfy6413aqpik9aj6p3a2syd1mda68-binutils-wrapper-2.31.1/bin:/nix/store/0y7jmqnj48ikjh37n3dl9kqw9hnn68nq-binutils-2.31.1/bin:/nix/store/f5wl80zkrd3fc1jxsljmnpn7y02lz6v1-glibc-2.27-bin/bin:/nix/store/d9s1kq1bnwqgxwcvv4zrc36ysnxg8gv7-coreutils-8.30/bin:/nix/store/mym79p27mpwc9ll22xfvchb3pizy4khw-remove-references-to/bin:/nix/store/9zz9j4vbg5wcl2yk5iib39i2llwmbnvr-hpack-0.31.2/bin:/nix/store/s7p0wfbdfbq307zgifhnh6w8sfjvy64y-patchelf-0.9/bin:/nix/store/gis2bz09gr9sgv1xiimyszcgv2grknpj-ncurses-6.1-20190112/bin:/nix/store/lm23hiidl4ffrx6137zf4zga84zb8x65-pretty-show-1.9.5/bin:/nix/store/gvshp9yvc6gql09r3cyryj2zgsnfk6br-ghc-8.6.4/bin:/nix/store/ghzg4kg0sjif58smj2lfm2bdvjwim85y-gcc-wrapper-7.4.0/bin:/nix/store/d4n93jn9fdq8fkmkm1q8f32lfagvibjk-gcc-7.4.0/bin:/nix/store/f5wl80zkrd3fc1jxsljmnpn7y02lz6v1-glibc-2.27-bin/bin:/nix/store/d9s1kq1bnwqgxwcvv4zrc36ysnxg8gv7-coreutils-8.30/bin:/nix/store/rbpyfy6413aqpik9aj6p3a2syd1mda68-binutils-wrapper-2.31.1/bin:/nix/store/0y7jmqnj48ikjh37n3dl9kqw9hnn68nq-binutils-2.31.1/bin:/nix/store/f5wl80zkrd3fc1jxsljmnpn7y02lz6v1-glibc-2.27-bin/bin:/nix/store/d9s1kq1bnwqgxwcvv4zrc36ysnxg8gv7-coreutils-8.30/bin:/nix/store/gis2bz09gr9sgv1xiimyszcgv2grknpj-ncurses-6.1-20190112/bin:/nix/store/d9s1kq1bnwqgxwcvv4zrc36ysnxg8gv7-coreutils-8.30/bin:/nix/store/krhqmaqal0gklh15rs2bwrqzz8mg9lrn-findutils-4.6.0/bin:/nix/store/pmzw4y4465zmq0dc8r4xbwyrqsaj4s70-diffutils-3.7/bin:/nix/store/x1khw8x0465xhkv6w31af75syyyxc65j-gnused-4.7/bin:/nix/store/wnjv27b3j6jfdl0968xpcymlc7chpqil-gnugrep-3.3/bin:/nix/store/vvwggp5mni64yavsfqmbwvm1mn692ssn-gawk-4.2.1/bin:/nix/store/wmxqm38g1y1y7sd7s9vg7an3klffaiyz-gnutar-1.31/bin:/nix/store/ix2q5vnynzfgsi4nqj8pmcbx2kf78wrm-gzip-1.10/bin:/nix/store/b7x2qjfs6k1xk4p74zzs9kyznv29zap6-bzip2-1.0.6.0.1-bin/bin:/nix/store/8n7v99ii7cg694pz0cfch422zvkdqfv4-gnumake-4.2.1/bin:/nix/store/cinw572b38aln37glr0zb8lxwrgaffl4-bash-4.4-p23/bin:/nix/store/kafrvdnj0gadm2p9alh20xiimkmw8xwz-patch-2.7.6/bin:/nix/store/zrazw25gy012ip7vcqddw6lcc393qvcg-xz-5.2.4-bin/bin:/home/neo/bin:/run/wrappers/bin:/home/neo/.local/bin:/home/neo/.nix-profile/bin:/etc/profiles/per-user/neo/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin"
2019-08-19 21:29:01.363818: [debug] Using a nix-shell environment from file: /home/neo/Projects/fairy-tale-artificial-general-intelligence-solutions/Sources/Razvan Flavius Panda/Haskell/artificial-general-intelligence/shell.nix
2019-08-19 21:29:01.365039: [debug] Run process: /run/current-system/sw/bin/nix-shell --pure "/home/neo/Projects/fairy-tale-artificial-general-intelligence-solutions/Sources/Razvan Flavius Panda/Haskell/artificial-general-intelligence/shell.nix" --arg ghc "with (import <nixpkgs> {}); haskell.compiler.ghc864" --run "'/nix/store/3gmxrznhj9gb3n2vj0cyp7a529755kwk-stack-2.1.3.1/bin/stack' $STACK_IN_NIX_EXTRA_ARGS '--internal-re-exec-version=2.1.3.1' 'build' '--verbose'"
2.1.3.1 x86_64 hpack-0.31.2
2019-08-19 21:29:08.456043: [debug] Checking for project config at: /home/neo/Projects/fairy-tale-artificial-general-intelligence-solutions/Sources/Razvan Flavius Panda/Haskell/artificial-general-intelligence/stack.yaml
2019-08-19 21:29:08.456351: [debug] Loading project config file stack.yaml
2019-08-19 21:29:08.466013: [debug] SELECT COUNT(*) FROM "last_performed" WHERE ("action"=?) AND ("timestamp">=?); [PersistInt64 1,PersistUTCTime 2019-08-18 20:29:08.465945169 UTC]
2019-08-19 21:29:08.466744: [debug] Using package location completions from a lock file
2019-08-19 21:29:08.680055: [debug] Running hpack on /home/neo/Projects/fairy-tale-artificial-general-intelligence-solutions/Sources/Razvan Flavius Panda/Haskell/artificial-general-intelligence/package.yaml
2019-08-19 21:29:08.685045: [debug] hpack output unchanged in /home/neo/Projects/fairy-tale-artificial-general-intelligence-solutions/Sources/Razvan Flavius Panda/Haskell/artificial-general-intelligence/artificial-general-intelligence.cabal
2019-08-19 21:29:08.688840: [debug] PATH is: Just "/nix/store/mn4jdnhkz12a6yd6jg6wvb4mqpxf8q1f-bash-interactive-4.4-p23/bin:/nix/store/92ra786kma8vpm2hklfypsjai9m7ra7l-ghc-8.6.4-with-packages/bin:/nix/store/gvshp9yvc6gql09r3cyryj2zgsnfk6br-ghc-8.6.4/bin:/nix/store/ghzg4kg0sjif58smj2lfm2bdvjwim85y-gcc-wrapper-7.4.0/bin:/nix/store/d4n93jn9fdq8fkmkm1q8f32lfagvibjk-gcc-7.4.0/bin:/nix/store/f5wl80zkrd3fc1jxsljmnpn7y02lz6v1-glibc-2.27-bin/bin:/nix/store/d9s1kq1bnwqgxwcvv4zrc36ysnxg8gv7-coreutils-8.30/bin:/nix/store/rbpyfy6413aqpik9aj6p3a2syd1mda68-binutils-wrapper-2.31.1/bin:/nix/store/0y7jmqnj48ikjh37n3dl9kqw9hnn68nq-binutils-2.31.1/bin:/nix/store/f5wl80zkrd3fc1jxsljmnpn7y02lz6v1-glibc-2.27-bin/bin:/nix/store/d9s1kq1bnwqgxwcvv4zrc36ysnxg8gv7-coreutils-8.30/bin:/nix/store/mym79p27mpwc9ll22xfvchb3pizy4khw-remove-references-to/bin:/nix/store/9zz9j4vbg5wcl2yk5iib39i2llwmbnvr-hpack-0.31.2/bin:/nix/store/s7p0wfbdfbq307zgifhnh6w8sfjvy64y-patchelf-0.9/bin:/nix/store/gis2bz09gr9sgv1xiimyszcgv2grknpj-ncurses-6.1-20190112/bin:/nix/store/gis2bz09gr9sgv1xiimyszcgv2grknpj-ncurses-6.1-20190112/bin:/nix/store/gvshp9yvc6gql09r3cyryj2zgsnfk6br-ghc-8.6.4/bin:/nix/store/ghzg4kg0sjif58smj2lfm2bdvjwim85y-gcc-wrapper-7.4.0/bin:/nix/store/d4n93jn9fdq8fkmkm1q8f32lfagvibjk-gcc-7.4.0/bin:/nix/store/f5wl80zkrd3fc1jxsljmnpn7y02lz6v1-glibc-2.27-bin/bin:/nix/store/d9s1kq1bnwqgxwcvv4zrc36ysnxg8gv7-coreutils-8.30/bin:/nix/store/rbpyfy6413aqpik9aj6p3a2syd1mda68-binutils-wrapper-2.31.1/bin:/nix/store/0y7jmqnj48ikjh37n3dl9kqw9hnn68nq-binutils-2.31.1/bin:/nix/store/f5wl80zkrd3fc1jxsljmnpn7y02lz6v1-glibc-2.27-bin/bin:/nix/store/d9s1kq1bnwqgxwcvv4zrc36ysnxg8gv7-coreutils-8.30/bin:/nix/store/gvshp9yvc6gql09r3cyryj2zgsnfk6br-ghc-8.6.4/bin:/nix/store/mym79p27mpwc9ll22xfvchb3pizy4khw-remove-references-to/bin:/nix/store/gis2bz09gr9sgv1xiimyszcgv2grknpj-ncurses-6.1-20190112/bin:/nix/store/gis2bz09gr9sgv1xiimyszcgv2grknpj-ncurses-6.1-20190112/bin:/nix/store/d9s1kq1bnwqgxwcvv4zrc36ysnxg8gv7-coreutils-8.30/bin:/nix/store/krhqmaqal0gklh15rs2bwrqzz8mg9lrn-findutils-4.6.0/bin:/nix/store/pmzw4y4465zmq0dc8r4xbwyrqsaj4s70-diffutils-3.7/bin:/nix/store/x1khw8x0465xhkv6w31af75syyyxc65j-gnused-4.7/bin:/nix/store/wnjv27b3j6jfdl0968xpcymlc7chpqil-gnugrep-3.3/bin:/nix/store/vvwggp5mni64yavsfqmbwvm1mn692ssn-gawk-4.2.1/bin:/nix/store/wmxqm38g1y1y7sd7s9vg7an3klffaiyz-gnutar-1.31/bin:/nix/store/ix2q5vnynzfgsi4nqj8pmcbx2kf78wrm-gzip-1.10/bin:/nix/store/b7x2qjfs6k1xk4p74zzs9kyznv29zap6-bzip2-1.0.6.0.1-bin/bin:/nix/store/8n7v99ii7cg694pz0cfch422zvkdqfv4-gnumake-4.2.1/bin:/nix/store/cinw572b38aln37glr0zb8lxwrgaffl4-bash-4.4-p23/bin:/nix/store/kafrvdnj0gadm2p9alh20xiimkmw8xwz-patch-2.7.6/bin:/nix/store/zrazw25gy012ip7vcqddw6lcc393qvcg-xz-5.2.4-bin/bin"
2019-08-19 21:29:08.691801: [debug] Using a nix-shell environment from file: /home/neo/Projects/fairy-tale-artificial-general-intelligence-solutions/Sources/Razvan Flavius Panda/Haskell/artificial-general-intelligence/shell.nix
2019-08-19 21:29:08.697221: [error] Executable named nix-shell not found on path: ["/nix/store/mn4jdnhkz12a6yd6jg6wvb4mqpxf8q1f-bash-interactive-4.4-p23/bin","/nix/store/92ra786kma8vpm2hklfypsjai9m7ra7l-ghc-8.6.4-with-packages/bin","/nix/store/gvshp9yvc6gql09r3cyryj2zgsnfk6br-ghc-8.6.4/bin","/nix/store/ghzg4kg0sjif58smj2lfm2bdvjwim85y-gcc-wrapper-7.4.0/bin","/nix/store/d4n93jn9fdq8fkmkm1q8f32lfagvibjk-gcc-7.4.0/bin","/nix/store/f5wl80zkrd3fc1jxsljmnpn7y02lz6v1-glibc-2.27-bin/bin","/nix/store/d9s1kq1bnwqgxwcvv4zrc36ysnxg8gv7-coreutils-8.30/bin","/nix/store/rbpyfy6413aqpik9aj6p3a2syd1mda68-binutils-wrapper-2.31.1/bin","/nix/store/0y7jmqnj48ikjh37n3dl9kqw9hnn68nq-binutils-2.31.1/bin","/nix/store/f5wl80zkrd3fc1jxsljmnpn7y02lz6v1-glibc-2.27-bin/bin","/nix/store/d9s1kq1bnwqgxwcvv4zrc36ysnxg8gv7-coreutils-8.30/bin","/nix/store/mym79p27mpwc9ll22xfvchb3pizy4khw-remove-references-to/bin","/nix/store/9zz9j4vbg5wcl2yk5iib39i2llwmbnvr-hpack-0.31.2/bin","/nix/store/s7p0wfbdfbq307zgifhnh6w8sfjvy64y-patchelf-0.9/bin","/nix/store/gis2bz09gr9sgv1xiimyszcgv2grknpj-ncurses-6.1-20190112/bin","/nix/store/gis2bz09gr9sgv1xiimyszcgv2grknpj-ncurses-6.1-20190112/bin","/nix/store/gvshp9yvc6gql09r3cyryj2zgsnfk6br-ghc-8.6.4/bin","/nix/store/ghzg4kg0sjif58smj2lfm2bdvjwim85y-gcc-wrapper-7.4.0/bin","/nix/store/d4n93jn9fdq8fkmkm1q8f32lfagvibjk-gcc-7.4.0/bin","/nix/store/f5wl80zkrd3fc1jxsljmnpn7y02lz6v1-glibc-2.27-bin/bin","/nix/store/d9s1kq1bnwqgxwcvv4zrc36ysnxg8gv7-coreutils-8.30/bin","/nix/store/rbpyfy6413aqpik9aj6p3a2syd1mda68-binutils-wrapper-2.31.1/bin","/nix/store/0y7jmqnj48ikjh37n3dl9kqw9hnn68nq-binutils-2.31.1/bin","/nix/store/f5wl80zkrd3fc1jxsljmnpn7y02lz6v1-glibc-2.27-bin/bin","/nix/store/d9s1kq1bnwqgxwcvv4zrc36ysnxg8gv7-coreutils-8.30/bin","/nix/store/gvshp9yvc6gql09r3cyryj2zgsnfk6br-ghc-8.6.4/bin","/nix/store/mym79p27mpwc9ll22xfvchb3pizy4khw-remove-references-to/bin","/nix/store/gis2bz09gr9sgv1xiimyszcgv2grknpj-ncurses-6.1-20190112/bin","/nix/store/gis2bz09gr9sgv1xiimyszcgv2grknpj-ncurses-6.1-20190112/bin","/nix/store/d9s1kq1bnwqgxwcvv4zrc36ysnxg8gv7-coreutils-8.30/bin","/nix/store/krhqmaqal0gklh15rs2bwrqzz8mg9lrn-findutils-4.6.0/bin","/nix/store/pmzw4y4465zmq0dc8r4xbwyrqsaj4s70-diffutils-3.7/bin","/nix/store/x1khw8x0465xhkv6w31af75syyyxc65j-gnused-4.7/bin","/nix/store/wnjv27b3j6jfdl0968xpcymlc7chpqil-gnugrep-3.3/bin","/nix/store/vvwggp5mni64yavsfqmbwvm1mn692ssn-gawk-4.2.1/bin","/nix/store/wmxqm38g1y1y7sd7s9vg7an3klffaiyz-gnutar-1.31/bin","/nix/store/ix2q5vnynzfgsi4nqj8pmcbx2kf78wrm-gzip-1.10/bin","/nix/store/b7x2qjfs6k1xk4p74zzs9kyznv29zap6-bzip2-1.0.6.0.1-bin/bin","/nix/store/8n7v99ii7cg694pz0cfch422zvkdqfv4-gnumake-4.2.1/bin","/nix/store/cinw572b38aln37glr0zb8lxwrgaffl4-bash-4.4-p23/bin","/nix/store/kafrvdnj0gadm2p9alh20xiimkmw8xwz-patch-2.7.6/bin","/nix/store/zrazw25gy012ip7vcqddw6lcc393qvcg-xz-5.2.4-bin/bin"]

Stack version

2.1.3.1 x86_64 hpack-0.31.2

Method of installation

Installed via Nix

Other details

If I set in the stack.yaml file: pure: false then the build fails with the issue mentioned in: https://github.com/commercialhaskell/stack/issues/5008

dbaynard commented 5 years ago

@nh2 does anything spring to mind, here?

qrilka commented 5 years ago

@razvan-flavius-panda I don't quite remember all the internal details of Stack invocation with Nix but the main thing is that Stack reexecutes itself with needed dependencies set up by a nix-shell. In your log I see that 2nd invocation doesn't see that it gets reexecuted so it tries to go 1 more level deeper and fails because of a different $PATH in pure nix-shell session. Probably something in your code breaks this Stack mechanism e.g. by unsetting $STACK_IN_NIX_SHELL.

PierreMardon commented 5 years ago

Hi ! I'm trying to have the haskell tools installed and working same problem with context and actions:

and here are my logs:

$> stack build --verbose
Version 2.1.3, Git revision 0fa51b9925decd937e4a993ad90cb686f88fa282 (7739 commits) x86_64 hpack-0.31.2
2019-09-01 11:11:54.939215: [debug] Checking for project config at: /Users/pierremardon/Haskell/hahp/stack.yaml
2019-09-01 11:11:54.939751: [debug] Loading project config file stack.yaml
2019-09-01 11:11:54.944505: [debug] SELECT COUNT(*) FROM "last_performed" WHERE ("action"=?) AND ("timestamp">=?); [PersistInt64 1,PersistUTCTime 2019-08-31 09:11:54.944433 UTC]
2019-09-01 11:11:54.945328: [debug] Using package location completions from a lock file
2019-09-01 11:11:55.059375: [debug] PATH is: Just "/Users/pierremardon/.cabal/bin:/Users/pierremardon/.ghcup/bin:/Users/pierremardon/Library/Python/3.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
2019-09-01 11:11:55.059440: [debug] Using a nix-shell environment with nix packages: blas, haskellPackages.hmatrix, openblasCompat, liblapack, haskell.compiler.ghc802, git, gcc, gmp
2019-09-01 11:11:55.065817: [error] Executable named nix-shell not found on path: ["/Users/pierremardon/.cabal/bin","/Users/pierremardon/.ghcup/bin","/Users/pierremardon/Library/Python/3.7/bin","/usr/local/bin","/usr/bin","/bin","/usr/sbin","/sbin"]

EDIT: I'm a total beginner in haskell's world and have no clue for now how an env variable could be overwritten. I tried with sh btw, and have the exact same result.

qrilka commented 5 years ago

@PierreMardon your case looks to be different from what the orginal poster has. Regarding your log it would be good to answer some questions: what's the stack.yaml you're using? Do you use system GHC option with Stack (otherwise ghcup looks to be superfluous as Stack by default manages GHC installation by itself)? It looks like you enable Nix mode in Stack, isn't it? Is nix-shell available by default in your $PATH?

akhesacaro-fretlink commented 3 years ago

I add the same problem, just in case someone stumbles upon this issue.

You should add the --no-nix flag to your stack command if invoking stack within --pure nix-shell.

Also, you probably have to add the --system-ghc flag to your stack command, to tell it to take ghc from the nix-shell.