haskell / ghcup-hs

https://www.haskell.org/ghcup/
GNU Lesser General Public License v3.0
287 stars 89 forks source link

documentation: system dependencies on (Ubuntu) Linux #421

Closed hasufell closed 1 year ago

hasufell commented 2 years ago

In GitLab by @ulysses4ever on Sep 9, 2022, 22:05

Just this week, I once again had to help a newcomer with setting up the Haskell toolchain on a fresh Ubuntu machine. The issue there is, as it's often the case with newcomers, the system is completely fresh and misses certain system dependencies. I don't see the list of dependencies for such a prolific use case in the User Guide. Would it be possible to add it somewhere? E.g. the Troubleshooting section. I should say the error I saw was quite bizarre (something like "preprocessor sanity check failed" on the configure step for GHC).

As far as I'm aware, this should be enough for Ubuntu (again, a vastly dominant variant of Linux, if include all the flavors and remixes):

$ sudo apt update
$ sudo apt install -y build-essential curl libffi-dev libffi7 libgmp-dev libgmp10 libncurses-dev libncurses5 libtinfo5
hasufell commented 2 years ago

In GitLab by @maerwald on Sep 10, 2022, 17:56

Required system dependencies are printed during installation.

The script even requires you to press enter before proceeding. You have to actively ignore the message 😅

hasufell commented 2 years ago

In GitLab by @ulysses4ever on Sep 10, 2022, 22:58

Good to know, thank you! My use-case for having those in the docs is that I can quickly copy and paste it to some novice who has trouble with the installation process. Unfortunately, novices usually not paying attention to the output. (It may also depend on the style and amount of output, and also whether they're prompted by the script to pay attention to the critical parts, but I don't wanna start that discussion here.)

Also, having a critical piece of requirements both in the output and in the docs is normal.

Of course, if you don't feel like supporting this use case, feel free to close.

hasufell commented 2 years ago

In GitLab by @maerwald on Sep 13, 2022, 22:46

ghcup-metadata has a helper tool for releases and stuff that already generates html table for some docs pages, see here https://github.com/haskell/ghcup-metadata/blob/master/ghcup-gen/Generate.hs#L128

The same pattern could be used to generate html for requirements per distro. PRs welcome.

hasufell commented 1 year ago

In GitLab by @brandonchinn178 on Nov 9, 2022, 13:39

Update: apologies, my actual problem was getting libnuma failures when installing ghcup itself (https://gitlab.haskell.org/haskell/ghcup-hs/-/issues/125#note_462017), so I didn't even get to the point of trying to install GHC

That being said, the output is a bit hidden in the logs

[ Info  ] downloading: https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-0.0.7.yaml as file /root/.ghcup/cache/ghcup-0.0.7.yaml
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  191k  100  191k    0     0   754k      0 --:--:-- --:--:-- --:--:--  755k
[ Info  ] Upgrading GHCup...
[ Warn  ] No GHCup update available

System requirements 
  Please ensure the following distro packages are installed before continuing (you can exit ghcup and return at any time): build-essential curl libffi-dev libffi8ubuntu1 libgmp-dev libgmp10 libncurses-dev libncurses5 libtinfo5
[ Info  ] downloading: https://downloads.haskell.org/~ghc/9.2.5/ghc-9.2.5-aarch64-deb10-linux.tar.xz as file /root/.ghcup/cache/ghc-9.2.5-aarch64-deb10-linux.tar.xz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  263M  100  263M    0     0  25.5M      0  0:00:10  0:00:10 --:--:-- 28.9M
[ Info  ] verifying digest of: ghc-9.2.5-aarch64-deb10-linux.tar.xz
[ Info  ] Unpacking: ghc-9.2.5-aarch64-deb10-linux.tar.xz to /root/.ghcup/tmp/ghcup-08cbf401caafe505
[ Info  ] Installing GHC (this may take a while)
[ ghc-configure ] checking for python3... no
[ ghc-configure ] checking for gcc... no
[ ghc-configure ] checking for clang... no
[ ghc-configure ] configure: error: in `/root/.ghcup/tmp/ghcup-08cbf401caafe505/ghc-9.2.5':
[ ghc-configure ] configure: error: no acceptable C compiler found in $PATH
[ ghc-configure ] See `config.log' for more details
[ Error ] Process "sh" with arguments ["./configure",
[ ...   ]                              "--prefix=/root/.ghcup/ghc/9.2.5"] failed with exit code 1.
[ Error ] Also check the logs in /root/.ghcup/logs
"_eghcup --cache install ghc recommended" failed!

Maybe it could be a bit more emphasized like

[ Info  ] downloading: https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-0.0.7.yaml as file /root/.ghcup/cache/ghcup-0.0.7.yaml
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  191k  100  191k    0     0   754k      0 --:--:-- --:--:-- --:--:--  755k
[ Info  ] Upgrading GHCup...
[ Warn  ] No GHCup update available

================================================================================
System requirements 
  Please ensure the following distro packages are installed before continuing (you can exit ghcup and return at any time): build-essential curl libffi-dev libffi8ubuntu1 libgmp-dev libgmp10 libncurses-dev libncurses5 libtinfo5
================================================================================

...
Original message @maerwald > The script even requires you to press enter before proceeding. You have to actively ignore the message I don't think this is true (or at least, not anymore; the link seems to be broken). In a fresh `docker run --rm -it ubuntu:latest`, I'm seeing ```console # curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | BOOTSTRAP_HASKELL_NONINTERACTIVE=1 sh Welcome to Haskell! This script can download and install the following binaries: * ghcup - The Haskell toolchain installer * ghc - The Glasgow Haskell Compiler * cabal - The Cabal build tool for managing Haskell software * stack - A cross-platform program for developing Haskell projects (similar to cabal) * hls - (optional) A language server for developers to integrate with their editor/IDE ghcup installs only into the following directory, which can be removed anytime: /root/.ghcup % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 51.5M 100 51.5M 0 0 20.7M 0 0:00:02 0:00:02 --:--:-- 20.7M /root/.ghcup/bin/ghcup: error while loading shared libraries: libnuma.so.1: cannot open shared object file: No such file or directory "_eghcup config set downloader Curl" failed! ``` ```console # curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh Welcome to Haskell! This script can download and install the following binaries: * ghcup - The Haskell toolchain installer * ghc - The Glasgow Haskell Compiler * cabal - The Cabal build tool for managing Haskell software * stack - A cross-platform program for developing Haskell projects (similar to cabal) * hls - (optional) A language server for developers to integrate with their editor/IDE ghcup installs only into the following directory, which can be removed anytime: /root/.ghcup Press ENTER to proceed or ctrl-c to abort. Note that this script can be re-run at any given time. ------------------------------------------------------------------------------- Do you want to install haskell-language-server (HLS)? HLS is a language-server that provides IDE-like functionality and can integrate with different editors, such as Vim, Emacs, VS Code, Atom, ... Also see https://haskell-language-server.readthedocs.io/en/stable/ [Y] Yes [N] No [?] Help (default is "N"). n ------------------------------------------------------------------------------- Do you want to enable better integration of stack with GHCup? This means that stack won't install its own GHC versions, but uses GHCup's. For more information see: https://docs.haskellstack.org/en/stable/yaml_configuration/#ghc-installation-customisation-experimental If you want to keep stacks vanilla behavior, answer 'No'. [Y] Yes [N] No [?] Help (default is "Y"). n % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 51.5M 100 51.5M 0 0 37.8M 0 0:00:01 0:00:01 --:--:-- 37.8M /root/.ghcup/bin/ghcup: error while loading shared libraries: libnuma.so.1: cannot open shared object file: No such file or directory "_eghcup config set downloader Curl" failed! ```
hasufell commented 1 year ago

In GitLab by @maerwald on Nov 9, 2022, 14:05

Yes it's true you don't get a list of system dependencies if ghcup itself fails to start. That's a GHC bug. They can't seem to fix the libnuma thing properly. You're also not running x86_64, which is statically linked and will never fail to start.

hasufell commented 1 year ago

In GitLab by @maerwald on Nov 10, 2022, 23:47

As explained in https://gitlab.haskell.org/haskell/ghcup-hs/-/issues/411#note_452686 ...PR welcome.

hasufell commented 1 year ago

In GitLab by @maerwald on Nov 12, 2022, 11:18

mentioned in commit 9fdc6eebe8097b326b3d00da5f3ae1ac333a4818

hasufell commented 1 year ago

In GitLab by @maerwald on Nov 12, 2022, 11:18

hasufell commented 1 year ago

In GitLab by @maerwald on Nov 12, 2022, 11:21

https://www.haskell.org/ghcup/install/#system-requirements

hasufell commented 1 year ago

In GitLab by @ulysses4ever on Nov 12, 2022, 12:41

Amazing, thank you! ♥️ 💙 💜

ulysses4ever commented 1 year ago

I just noticed that Stack does a very good job at running a system package manager to install dependencies during setup. Maybe you'd want to look at it and possibly copy it. The user is "only" required to sudo.

hasufell commented 1 year ago

I just noticed that Stack does a very good job at running a system package manager to install dependencies during setup. Maybe you'd want to look at it and possibly copy it. The user is "only" required to sudo.

Absolutely not.

This goes against the core design principles of GHCup, against unix philosophy and against safety standards (programs invoking sudo can do horrible things).

Also see: https://www.haskell.org/ghcup/about/#non-goals

Package managers are an extremely delicate matter. Invoking them via scripts is bad form and makes them untrustworthy.