Closed arbitrary-dev closed 4 years ago
The check
step does a stack --stack-yaml install/shake.yaml --numeric-version --verbosity=warn
, does it works if you invoke it directly in a shell? what is the stack version printed if any?
Nothing happens, except version is printed:
$ stack --stack-yaml install/shake.yaml --numeric-version --verbosity=warn
2.1.3
@arbitrary-dev Are you on NixOs?
Nope, Gentoo
Ok, to me it looks like there is some PATH isolation happening.
Can you to do something like this:
#!/usr/bin/env stack
-- stack --resolver lts-14.27 script
{-# LANGUAGE OverloadedStrings #-}
import System.Process
main :: IO ()
main = putStrLn =<< readProcess "stack" ["--numeric-version"] ""
and run it via stack exec
?
If this doesnt work, take a look at the PATH within the stack script:
#!/usr/bin/env stack
-- stack --resolver lts-14.27 script
{-# LANGUAGE OverloadedStrings #-}
import System.Environment
main :: IO ()
main = putStrLn =<< getEnv "PATH"
Is it altered in some way?
Yep, it has stack related dirs prepended to system's PATH
:
$ stack --resolver lts-15.4 script test-readProcess.hs
Using resolver: lts-15.4 specified on command line
Stack has not been tested with GHC versions above 8.6, and using 8.8.3, this may fail
Stack has not been tested with Cabal versions above 2.4, but version 3.0.1.0 was found, this may fail
test.hs: stack: readCreateProcess: runInteractiveProcess: exec: does not exist (No such file or directory)
$ stack --resolver lts-15.4 script test-getEnv.hs
Using resolver: lts-15.4 specified on command line
Stack has not been tested with GHC versions above 8.6, and using 8.8.3, this may fail
Stack has not been tested with Cabal versions above 2.4, but version 3.0.1.0 was found, this may fail
/home/man/.stack/.stack-work/install/x86_64-linux-tinfo6/26b7d0179e9fb44e938c38e6e2e5a33350a173316ead8d4118b87c40d077ab7b/8.8.3/bin:/home/man/.stack/snapshots/x86_64-linux-tinfo6/26b7d0179e9fb44e938c38e6e2e5a33350a173316ead8d4118b87c40d077ab7b/8.8.3/bin:/home/man/.stack/compiler-tools/x86_64-linux-tinfo6/ghc-8.8.3/bin:/home/man/.stack/programs/x86_64-linux/ghc-tinfo6-8.8.3/bin:<SYSTEM'S $PATH>
And your stack installation is not in one of these paths?
In my experience, easiest way to work around this is by compiling the runnable.
Does stack --resolver lts-15.4 ghc test-readProcess.hs
produce an executable? And if yes, can you execute it the executable and it has the desired behaviour?
Ok, I solved the issue. Thanks for help!
On my system, stack binary is called stack-bin
, so I created a stack
alias for it in bash sometime ago. Now I've removed the alias and made a link instead:
ln -s /usr/bin/stack-bin ~/.local/bin/stack