commercialhaskell / stack

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

Error while building `basement` with GHC 9.6.5 on Linux/x86_64 #6599

Open dan010 opened 4 weeks ago

dan010 commented 4 weeks ago

Encountered the error below while building the rpki-prover. I have been stacked for weeks on this error

basement > hsc2hs-ghc-9.6.5: .stack-work/dist/x86_64-linux-tinfo6/ghc-9.6.5/build/Basement/Terminal/Size_hsc_make: createProcess: posix_spawnp: permission denied (Permission denied)

mpilgrem commented 4 weeks ago

@dan010, I see you are on Linux/x86_64 - what distribution? Also, what snapshot? Is your problem specific to GHC 9.6.5 and hsc2hs-ghc-9.6.5?

I see https://github.com/haskell-foundation/foundation has been archived since 2023-09-20. Does that mean basement is no longer maintained?

I see you have raised:

mpilgrem commented 4 weeks ago

On Ubuntu 22.04.13 (via WSL 2), I could not reproduce a problem building basement in isolation:

$ stack unpack basement
$ cd basement-0.0.16
$ stack init # Picks lts-22.24 (GHC 9.6.5)
$ stack build
dan010 commented 4 weeks ago

I think my problem is on .stack-work symlinked onto a noexec filesystem since it have a permission denied on error message. But I just don't know how to troubleshoot it or fix it

mpilgrem commented 4 weeks ago

Describe your Stack setup: what version are you using (stack --version)? How did you install Stack?

EDIT: Can you build basement in isolation, like I did in my post above?

dan010 commented 4 weeks ago

Describe your Stack setup: what version are you using (stack --version)? How did you install Stack?

EDIT: Can you build basement in isolation, like I did in my post above?

The version of stack is Version 2.15.7, Git revision f590e0165b5ab92f5f7f87f8aa55852e1972ee25 x86_64 hpa ck-0.36.0

and this is the command that I used to install the stack curl -sSL https://get.haskellstack.org/ | sh

mpilgrem commented 4 weeks ago

I could not reproduce the problem building rpki-prover on Ubuntu 22.04.13 (via WSL 2):

$ git clone https://github.com/lolepezy/rpki-prover.git
$ cd rpki-prover
$ cp package-template.yaml package.yaml
$ sudo apt-get install ... # Install missing C libraries
$ stack build
...
rpki-prover                  > copy/register
Installing library in .../rpki-prover/.stack-work/install/x86_64-linux-tinfo6/29f0bb150080a27478147fb33b836f432c34eac00995111c1e969189e12a621d/9.6.5/lib/x86_64-linux-ghc-9.6.5/rpki-prover-0.9.3-2RYavTphtkE8c7OjKmjC4C
Installing executable rpki-prover in .../rpki-prover/.stack-work/install/x86_64-linux-tinfo6/29f0bb150080a27478147fb33b836f432c34eac00995111c1e969189e12a621d/9.6.5/bin
Registering library for rpki-prover-0.9.3..
Completed 179 action(s).
hasufell commented 4 weeks ago

I think my problem is on .stack-work symlinked onto a noexec filesystem since it have a permission denied on error message.

I don't think noexec filesystems are expected to work.

dan010 commented 4 weeks ago

I could not reproduce the problem building rpki-prover on Ubuntu 22.04.13 (via WSL 2):

$ git clone https://github.com/lolepezy/rpki-prover.git
$ cd rpki-prover
$ cp package-template.yaml package.yaml
$ sudo apt-get install ... # Install missing C libraries
$ stack build
...
rpki-prover                  > copy/register
Installing library in .../rpki-prover/.stack-work/install/x86_64-linux-tinfo6/29f0bb150080a27478147fb33b836f432c34eac00995111c1e969189e12a621d/9.6.5/lib/x86_64-linux-ghc-9.6.5/rpki-prover-0.9.3-2RYavTphtkE8c7OjKmjC4C
Installing executable rpki-prover in .../rpki-prover/.stack-work/install/x86_64-linux-tinfo6/29f0bb150080a27478147fb33b836f432c34eac00995111c1e969189e12a621d/9.6.5/bin
Registering library for rpki-prover-0.9.3..
Completed 179 action(s).

I am using a rhel 9 not ubuntu.

mpilgrem commented 3 weeks ago

@dan010, I don't have access to Red Hat Enterprise Linux 9, but it seems to me unlikely that it cannot do what Ubuntu 22.04.13 can do.

On the subject a 'no-exec' filesystem, your original problem appears to be with the hsc2hs-ghc-9.6.5 executable. That executable is located in the same directory as GHC itself (see stack path --compiler-bin for its location). What is does is create a C program that gets automatically compiled and run. That program outputs Haskell code. See: https://downloads.haskell.org/ghc/9.6.5/docs/users_guide/utils.html#writing-haskell-interfaces-to-c-code-hsc2hs

I assume that happens in the Cabal library's dist directory (see stack path --dist-dir for its location). If that location is somewhere where an executable file is forbidden to execute, then it is not surprising that your build is failing. The solution is to move the Haskell project to a location where executables can execute.

dan010 commented 3 weeks ago

@dan010, I don't have access to Red Hat Enterprise Linux 9, but it seems to me unlikely that it cannot do what Ubuntu 22.04.13 can do.

On the subject a 'no-exec' filesystem, your original problem appears to be with the hsc2hs-ghc-9.6.5 executable. That executable is located in the same directory as GHC itself (see stack path --compiler-bin for its location). What is does is create a C program that gets automatically compiled and run. That program outputs Haskell code. See: https://downloads.haskell.org/ghc/9.6.5/docs/users_guide/utils.html#writing-haskell-interfaces-to-c-code-hsc2hs

I assume that happens in the Cabal library's dist directory (see stack path --dist-dir for its location). If that location is somewhere where an executable file is forbidden to execute, then it is not surprising that your build is failing. The solution is to move the Haskell project to a location where executables can execute.

Here is the output of stack path --dist-dir Warning: Warning (added by new or init): Some packages were found to be incompatible with the resolver and have been left commented out in the packages section. You can omit this message by removing it from stack.yaml .stack-work/dist/x86_64-linux-tinfo6/ghc-9.4.8

when I tried to access this path .stack-work/dist/x86_64-linux-tinfo6/ghc-9.4.8 it return no such file or directory

mpilgrem commented 3 weeks ago

@dan010, that output is odd on two counts:

I suggest you start from scratch:

dan010 commented 3 weeks ago

@dan010, that output is odd on two counts:

I suggest you start from scratch:

  • delete the Stack root (likely ~/.stack, stack path --stack-root will confirm where)
  • perhaps, also delete the Stack executable (at which stack) and reinstall Stack
  • delete the rpki-prover project directory and re-clone it (somewhere where executables have permission to execute) - follow the same steps as those I set out above.

Do you have a recommended way on how to reinstall the stack?

mpilgrem commented 3 weeks ago

@dan010, you have two main choices to install Stack:

You'll want to install GHCup anyway if (a) you are using the Haskell add-ins for popular code file editors, such as Visual Studio Code and/or (b) you are using Cabal (the tool).

dan010 commented 3 weeks ago

@dan010, you have two main choices to install Stack:

You'll want to install GHCup anyway if (a) you are using the Haskell add-ins for popular code file editors, such as Visual Studio Code and/or (b) you are using Cabal (the tool).

I also tried to install GHCup but I encountered error as well.

mpilgrem commented 2 weeks ago

@dan010, absent better information about how the system on which you are seeking to use Haskell tools is configured and what you are experiencing when you try to install/use them, I think I can't provide further help. It does not appear to relate to Stack's code base. GHCup's repository is here: https://github.com/haskell/ghcup-hs/issues. Can we close this issue?