haskell / haskell-ide-engine

The engine for haskell ide-integration. Not an IDE
BSD 3-Clause "New" or "Revised" License
2.38k stars 213 forks source link

Unable to build hie: ... exec: does not exist (No such file or directory) #1747

Closed arbitrary-dev closed 4 years ago

arbitrary-dev commented 4 years ago
$ git log --oneline | cat
16d1a63 Merge pull request #1742 from ssanj/patch-1

$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.8.3

$ stack ./install.hs hie-8.8.3
# stack (for check)  
Error when running Shake build system:
  at want, called at src/Development/Shake/Internal/Args.hs:83:69 in shake-0.18.5-44KSA7uQF2VObxzEvLYZx:Development.Shake.Internal.Args
* Depends on: hie-8.8.3
  at apply1, called at src/Development/Shake/Internal/Rules/Rerun.hs:41:5 in shake-0.18.5-44KSA7uQF2VObxzEvLYZx:Development.Shake.Internal.Rules.Rerun
* Depends on: check
* Raised the exception:
stack: createProcess: runInteractiveProcess: exec: does not exist (No such file or directory)
jneira commented 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?

arbitrary-dev commented 4 years ago

Nothing happens, except version is printed:

$ stack --stack-yaml install/shake.yaml --numeric-version --verbosity=warn            
2.1.3
fendor commented 4 years ago

@arbitrary-dev Are you on NixOs?

arbitrary-dev commented 4 years ago

Nope, Gentoo

fendor commented 4 years ago

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?

arbitrary-dev commented 4 years ago

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>
fendor commented 4 years ago

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?

arbitrary-dev commented 4 years ago

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