gregwebs/Shelly.hs

PATH reported by shelly does not match PATH in shell

Opened this issue · 0 comments

Below, it seems that shelly is unable to find the desired executable under /run/current-system/sw/bin, even though it is on the PATH:

$ ./nix_shelly.hs
nix_shelly.hs: 
Ran commands: 
nix-shell -p cargo
which nix-shell

Exception: user error (shelly did not find nix-shell in the PATH: /home/brandon/.stack/.stack-work/install/x86_64-linux-nix/f300697f261dbca3ad91f0f5a4ba0a6c83c9afca64230e61b252e8221db8ca4e/8.6.5/bin:/home/brandon/.stack/snapshots/x86_64-linux-nix/f300697f261dbca3ad91f0f5a4ba0a6c83c9afca64230e61b252e8221db8ca4e/8.6.5/bin:/home/brandon/.stack/compiler-tools/x86_64-linux-nix/ghc-8.6.5/bin:/nix/store/hg3na12737n7wws1kndxvs95ai88fgn8-ghc-8.6.5/bin:/nix/store/lb3hli8d9536g45mndwfwyi6fpny0blh-bash-interactive-4.4-p23/bin:/nix/store/2xwxj5qrrc71asdk1wyq19nz9k845pzs-patchelf-0.9/bin:/nix/store/hg3na12737n7wws1kndxvs95ai88fgn8-ghc-8.6.5/bin:/nix/store/291ldi6fqsbmkbvbs8is4mcg3jb64ld4-gcc-wrapper-8.3.0/bin:/nix/store/62x7m20m7lm8y8s17cbgha0sf3cmma19-gcc-8.3.0/bin:/nix/store/hblpx8x5w88igmwa4ydnsnb65s363lji-glibc-2.27-bin/bin:/nix/store/9v78r3afqy9xn9zwdj9wfys6sk3vc01d-coreutils-8.31/bin:/nix/store/gwwycf3w6cbj0gd2mpgblrdjc24f3cys-binutils-wrapper-2.31.1/bin:/nix/store/ajrrkivdfvp8dp4vdg5hp1h5hblmanc9-binutils-2.31.1/bin:/nix/store/hblpx8x5w88igmwa4ydnsnb65s363lji-glibc-2.27-bin/bin:/nix/store/9v78r3afqy9xn9zwdj9wfys6sk3vc01d-coreutils-8.31/bin:/nix/store/06q8j7z84zqjzcijvz90i4v7j5mfk4jl-git-2.23.1/bin:/nix/store/my5v4x1n5568vgziyc63vmc97nk8ril9-ncurses-6.1-20190112/bin:/nix/store/9v78r3afqy9xn9zwdj9wfys6sk3vc01d-coreutils-8.31/bin:/nix/store/0zdsw4qdrwi41mfdwqpxknsvk9fz3gkb-findutils-4.7.0/bin:/nix/store/dys98skw6ifw5qsqrhjxjjiydyfbg3nq-diffutils-3.7/bin:/nix/store/g2h4491kab7l06v9rf1lnyjvzdwy5ak0-gnused-4.7/bin:/nix/store/71y5ddyz8vmsw9wgi3gzifcls53r60i9-gnugrep-3.3/bin:/nix/store/84yafwjc6sga23vwsbahhymikjhfbnw4-gawk-5.0.1/bin:/nix/store/aawf0q16ql39w2gwv52qyjfzgbg5f22r-gnutar-1.32/bin:/nix/store/afyqk8219zfv5and3pqahzvn6bpmx3dq-gzip-1.10/bin:/nix/store/iws7dm1jij4lv09mbpwf9i8lc1d4b798-bzip2-1.0.6.0.1-bin/bin:/nix/store/j8fq1ksp37w88rx80blzazldi17f3x7s-gnumake-4.2.1/bin:/nix/store/rm1hz1lybxangc8sdl7xvzs5dcvigvf7-bash-4.4-p23/bin:/nix/store/lmi2nqb1cfzr3ps2zkq97q88zzkhp4mj-patch-2.7.6/bin:/nix/store/y04xj2mbc66zs53fackn1wwlrv31bv3y-xz-5.2.4-bin/bin:/nix/store/gwwycf3w6cbj0gd2mpgblrdjc24f3cys-binutils-wrapper-2.31.1/bin:/nix/store/9v78r3afqy9xn9zwdj9wfys6sk3vc01d-coreutils-8.31/bin:/nix/store/gwwycf3w6cbj0gd2mpgblrdjc24f3cys-binutils-wrapper-2.31.1/bin:/nix/store/9v78r3afqy9xn9zwdj9wfys6sk3vc01d-coreutils-8.31/bin)

[nix-shell:~/workspace]$ which nix-shell 
/run/current-system/sw/bin/nix-shell

[nix-shell:~/workspace]$ echo $PATH
/nix/store/lb3hli8d9536g45mndwfwyi6fpny0blh-bash-interactive-4.4-p23/bin:/nix/store/2xwxj5qrrc71asdk1wyq19nz9k845pzs-patchelf-0.9/bin:/nix/store/291ldi6fqsbmkbvbs8is4mcg3jb64ld4-gcc-wrapper-8.3.0/bin:/nix/store/
62x7m20m7lm8y8s17cbgha0sf3cmma19-gcc-8.3.0/bin:/nix/store/hblpx8x5w88igmwa4ydnsnb65s363lji-glibc-2.27-bin/bin:/nix/store/9v78r3afqy9xn9zwdj9wfys6sk3vc01d-coreutils-8.31/bin:/nix/store/gwwycf3w6cbj0gd2mpgblrdjc24
f3cys-binutils-wrapper-2.31.1/bin:/nix/store/ajrrkivdfvp8dp4vdg5hp1h5hblmanc9-binutils-2.31.1/bin:/nix/store/hblpx8x5w88igmwa4ydnsnb65s363lji-glibc-2.27-bin/bin:/nix/store/9v78r3afqy9xn9zwdj9wfys6sk3vc01d-coreut
ils-8.31/bin:/nix/store/9rmkkh1ylmdqn3cqbssnndw5fg51zyl1-stack-2.1.3.1/bin:/nix/store/9v78r3afqy9xn9zwdj9wfys6sk3vc01d-coreutils-8.31/bin:/nix/store/0zdsw4qdrwi41mfdwqpxknsvk9fz3gkb-findutils-4.7.0/bin:/nix/stor
e/dys98skw6ifw5qsqrhjxjjiydyfbg3nq-diffutils-3.7/bin:/nix/store/g2h4491kab7l06v9rf1lnyjvzdwy5ak0-gnused-4.7/bin:/nix/store/71y5ddyz8vmsw9wgi3gzifcls53r60i9-gnugrep-3.3/bin:/nix/store/84yafwjc6sga23vwsbahhymikjhf
bnw4-gawk-5.0.1/bin:/nix/store/aawf0q16ql39w2gwv52qyjfzgbg5f22r-gnutar-1.32/bin:/nix/store/afyqk8219zfv5and3pqahzvn6bpmx3dq-gzip-1.10/bin:/nix/store/iws7dm1jij4lv09mbpwf9i8lc1d4b798-bzip2-1.0.6.0.1-bin/bin:/nix/
store/j8fq1ksp37w88rx80blzazldi17f3x7s-gnumake-4.2.1/bin:/nix/store/rm1hz1lybxangc8sdl7xvzs5dcvigvf7-bash-4.4-p23/bin:/nix/store/lmi2nqb1cfzr3ps2zkq97q88zzkhp4mj-patch-2.7.6/bin:/nix/store/y04xj2mbc66zs53fackn1w
wlrv31bv3y-xz-5.2.4-bin/bin:/home/brandon/bin:/run/wrappers/bin:/home/brandon/.nix-profile/bin:/etc/profiles/per-user/brandon/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin

The program I used was:

#!/usr/bin/env stack
{- stack script --nix --resolver lts-14.27
     --package async
     --package shelly
-}

{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ExtendedDefaultRules #-}
{-# OPTIONS_GHC -fno-warn-type-defaults #-}
  
import Shelly

main :: IO ()
main = shelly $ do
  run_ "nix-shell" ["-p", "cargo"]
  run_ "cargo" []