Skip to content

Stack error re dash shell on Ubuntu 22 #5888

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
andrewbernard opened this issue Sep 29, 2022 · 6 comments
Closed

Stack error re dash shell on Ubuntu 22 #5888

andrewbernard opened this issue Sep 29, 2022 · 6 comments

Comments

@andrewbernard
Copy link

Please use the following schema for your bug report:

General summary/comments (optional)

Stack fails on shell script ghc-install,sh because it uses set -euo pipefile and the script uses #!/bin/sh. Sh has been linked to dash for a long time in Ubuntu and pipefile is not supported in dash.

Steps to reproduce

Run stack build on any project.

Expected

Should run correctly without error.

Actual

Failure as follows:

$ stack build
/home/acb/.stack/hooks/ghc-install.sh: 6: set: Illegal option -o pipefail
GHC install hook exited with code: 2

Stack version

stack --version
Version 2.9.1, Git revision 409d56031b4240221d656db09b2ba476fe6bb5b1 x86_64 hpack-0.35.0

Method of installation

  • Via GHCup
@andrewbernard andrewbernard changed the title Stack error re dash shell on Ubuntu Stack error re dash shell on Ubuntu 22 Sep 29, 2022
@hasufell
Copy link
Contributor

hasufell commented Sep 29, 2022

Not exactly true. The script uses /bin/bash: https://gitlab.haskell.org/haskell/ghcup-hs/-/blob/master/scripts/hooks/stack/ghc-install.sh#L1

But stack invokes via sh:

(exit, out) <- withProcessContext menv $ proc "sh" [toFilePath hook] readProcessStdout

I don't know if there is a reliable way to respect the shebang across platforms.

@hasufell
Copy link
Contributor

A workaround is to make the script posix compatible. I can do that and upload the script again.

@hasufell
Copy link
Contributor

Run this to update:

curl --proto '=https' --tlsv1.2 -sSf https://www.haskell.org/ghcup/sh/hooks/stack/ghc-install.sh > ~/.stack/hooks/ghc-install.sh

This is my tests:

$ cat ~/.stack/hooks/ghc-install.sh                                                      Fri 07:30
#!/bin/sh

# !! KEEP THIS SCRIPT POSIX COMPLIANT !!

# see https://docs.haskellstack.org/en/stable/yaml_configuration/#ghc-installation-customisation-experimental
# for documentation about hooks

set -eu

case $HOOK_GHC_TYPE in
    bindist)
        ghcdir=$(ghcup run --ghc "$HOOK_GHC_VERSION" --install) || exit 3
        printf "%s/ghc" "${ghcdir}"
        ;;
    git)
        # TODO: should be somewhat possible
        >&2 echo "Hook doesn't support installing from source"
        exit 1
        ;;
    *)
        >&2 echo "Unsupported GHC installation type: $HOOK_GHC_TYPE"
        exit 2
        ;;
esac
 ~/g/ghcup-hs   master    
$ stack exec ghc -- -v0 -package-env=- -ignore-dot-ghci -e 'Control.Monad.join (Control.Monad.fmap System.IO.putStr System.Environment.getExecutablePath)'
[ Info  ] downloading: https://github.com/raw/haskell/ghcup-metadata/master/ghcup-0.0.7.yaml as file /home/hasufell/.ghcup/cache/ghcup-0.0.7.yaml
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
[ Info  ] downloading: https://github.com/raw/haskell/ghcup-metadata/master/ghcup-prereleases-0.0.7.yaml as file /home/hasufell/.ghcup/cache/ghcup-prereleases-0.0.7.yaml
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
/home/hasufell/.ghcup/ghc/8.10.7/lib/ghc-8.10.7/bin/ghc⏎       

@andrewbernard
Copy link
Author

andrewbernard commented Oct 11, 2022 via email

@hasufell
Copy link
Contributor

hasufell commented Oct 11, 2022

Yes, dash scripts need to be POSIX compatible. Ubuntu moved /bin/sh to
dash at Ubuntu 6 and we are now at 22. Why has nobody else ever seen
this issue? Odd.

On 29/09/2022 4:05 pm, Julian Ospald wrote:

A workaround is to make the script posix compatible. I can do that and
upload the script again.


Reply to this email directly, view it on GitHub
#5888 (comment),
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AA6S56ZAW2JEOVLY626DWR3WAUWTDANCNFSM6AAAAAAQYNERWE.
You are receiving this because you authored the thread.Message ID:
@.***>

Did you follow my instructions?

@mpilgrem
Copy link
Member

I am going to close this issue here because commits have been made to the GHCup repository on GitLab to resolve the issue: https://gitlab.haskell.org/haskell/ghcup-hs/-/commit/9902adab6d83e24106edf5ff804fbd60a563b765.

hasufell added a commit to hasufell/ghcup-hs that referenced this issue Oct 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants