hie-bios icon indicating copy to clipboard operation
hie-bios copied to clipboard

Couldn't execute stack setup --silent

Open mkoloberdin opened this issue 4 years ago • 8 comments

I am experiencing a problem with stack projects both while manually running hie-bios as well as via HLS. Here is an excerpt from VSCodium's log (HLS version 1.4.0, OS: Arch Linux):

setInitialDynFlags cradle: Cradle {cradleRootDir = "/path-to-my-project", cradleOptsProg = CradleAction: Stack}
Couldn't load cradle for libdir: (CradleError {cradleErrorDependencies = [], cradleErrorExitCode = ExitSuccess, cradleErrorStderr = ["Couldn't execute stack setup --silent"]},"/path-to-my-project",Nothing,Cradle {cradleRootDir = "/path-to-my-project", cradleOptsProg = CradleAction: Stack})

Note the cradleErrorExitCode = ExitSuccess yet cradleErrorStderr = ["Couldn't execute stack setup --silent"].

Originally posted by @mkoloberdin in https://github.com/haskell/haskell-language-server/issues/236#issuecomment-921837122

mkoloberdin avatar Sep 17 '21 15:09 mkoloberdin

If I modify the stackCradle function in Cradle.hs to run stack via env -S ... this issue goes away but hie-bios then dies with this error message:

hie-bios: stack: streamingProcess: exec: invalid argument (Bad file descriptor)

mkoloberdin avatar Sep 18 '21 18:09 mkoloberdin

What happens if you execute stack setup in the root of your project? What is the error message?

fendor avatar Sep 20 '21 09:09 fendor

It works fine. No error message but this goes to stderr:

stack will use a sandboxed GHC it installed
For more information on paths, see 'stack path' and 'stack exec env'
To use this GHC and packages outside of a project, consider using:
stack ghc, stack ghci, stack runghc, or stack exec

If I do a rm -rf ~/.stack first, then this gets spit out to stderr:

Preparing to install GHC (tinfo6) to an isolated location.
This will not interfere with any system-level installation.
Downloaded ghc-tinfo6-8.10.7.                                      
Installed GHC.                                                                        
stack will use a sandboxed GHC it installed
For more information on paths, see 'stack path' and 'stack exec env'
To use this GHC and packages outside of a project, consider using:
stack ghc, stack ghci, stack runghc, or stack exec

mkoloberdin avatar Sep 20 '21 09:09 mkoloberdin

And stack setup --silent does not fail with an error-code?

fendor avatar Sep 20 '21 10:09 fendor

Nope:

$ stack setup --silent && echo "Success"
Success

mkoloberdin avatar Sep 20 '21 11:09 mkoloberdin

but hie-bios fails, claiming it can't execute stack setup --silent? Can you change that to stack setup instead (in hie-bios), so you see stdout and stderr in the error message.

fendor avatar Sep 20 '21 13:09 fendor

I've hit this issue as well (running on an M1 mac). Changing to stack setup in hie-bios gave the following besides Couldn't execute stack setup --silent:

Failed to get project GHC version:CradleError {cradleErrorDependencies = [], cradleErrorExitCode = ExitFailure 1, cradleErrorStderr = ["Error when calling stack setup","","The GHC located at /Users/dani/.stack/programs/aarch64-osx/ghc-8.10.7/bin/ghc-8.10.7 failed to compile a sanity check. Please see:\n\n    http://docs.haskellstack.org/en/stable/install_and_upgrade/\n\nfor more information. Exception was:\nReceived ExitFailure 1 when running\nRaw command: /Users/dani/.stack/programs/aarch64-osx/ghc-8.10.7/bin/ghc-8.10.7 /private/var/folders/bb/ylwx59tn6136lc7m0vth80_c0000gp/T/stack-sanity-check-9692de1554b0c717/Main.hs -no-user-package-db\nRun from: /private/var/folders/bb/ylwx59tn6136lc7m0vth80_c0000gp/T/stack-sanity-check-9692de1554b0c717/\nStandard output:\n\n[1 of 1] Compiling Main             ( /private/var/folders/bb/ylwx59tn6136lc7m0vth80_c0000gp/T/stack-sanity-check-9692de1554b0c717/Main.hs, /private/var/folders/bb/ylwx59tn6136lc7m0vth80_c0000gp/T/stack-sanity-check-9692de1554b0c717/Main.o )\nStandard error:\n\n\n<no location info>: error:\n    Warning: Couldn't figure out LLVM version!\n             Make sure you have installed LLVM between [9 and 13)\nghc: could not execute: opt\n\n"]}

Formatted cradleErrorStderr:

The GHC located at /Users/dani/.stack/programs/aarch64-osx/ghc-8.10.7/bin/ghc-8.10.7 failed to compile a sanity check. Please see:

    http://docs.haskellstack.org/en/stable/install_and_upgrade/

for more information. Exception was:
Received ExitFailure 1 when running
Raw command: /Users/dani/.stack/programs/aarch64-osx/ghc-8.10.7/bin/ghc-8.10.7 /private/var/folders/bb/ylwx59tn6136lc7m0vth80_c0000gp/T/stack-sanity-check-9692de1554b0c717/Main.hs -no-user-package-db
Run from: /private/var/folders/bb/ylwx59tn6136lc7m0vth80_c0000gp/T/stack-sanity-check-9692de1554b0c717/
Standard output:

[1 of 1] Compiling Main             ( /private/var/folders/bb/ylwx59tn6136lc7m0vth80_c0000gp/T/stack-sanity-check-9692de1554b0c717/Main.hs, /private/var/folders/bb/ylwx59tn6136lc7m0vth80_c0000gp/T/stack-sanity-check-9692de1554b0c717/Main.o )
Standard error:


<no location info>: error:
    Warning: Couldn't figure out LLVM version!
             Make sure you have installed LLVM between [9 and 13)
ghc: could not execute: opt

brew link llvm@12 fixed the issue for me!

EpicOrange avatar Oct 17 '21 16:10 EpicOrange

but hie-bios fails, claiming it can't execute stack setup --silent? Can you change that to stack setup instead (in hie-bios), so you see stdout and stderr in the error message.

Just tried this with no other modifications and lts-18.7:

$ hie-bios check .
hie-bios: CradleError {cradleErrorDependencies = [], cradleErrorExitCode = ExitSuccess, cradleErrorStderr = ["Couldn't execute stack setup"]}

mkoloberdin avatar Nov 18 '21 14:11 mkoloberdin

Closed, this seems to be not happening anymore?

Feel free to reopen if you still suffer from this.

fendor avatar Jun 16 '23 16:06 fendor