ghcup install: Permission denied when writing to ~/.ghcup/cache directory

1.1k Views Asked by At

I'm attempting to install ghcup on Ubuntu with:

curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh

using the default options (prepend to .bashrc, don't install HLS, dont install Stack).

The problem is that I'm receiving a permission denied error when the script attempts to write the ghcup-0.0.6.yaml.tmp file to the ~/.ghcup/cache directory and I'm not sure why.

Permissions on the directory are 1775 (drwxrwxr-x). Upgrading them to 1777 (drwxrwxrwt) and re-running the curl command produces the same error. The directory owner is me (not root), and I'm running the curl command without sudo as directed by the ghcup installation instructions.

Full command output:

                                 Dload  Upload   Total   Spent    Left  Speed
100 24.3M  100 24.3M    0     0  5782k      0  0:00:04  0:00:04 --:--:-- 5783k
[ Info  ] downloading: https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-0.0.6.yaml as file /home/austin/.ghcup/cache/ghcup-0.0.6.yaml
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0Warning: Failed to create the file 
Warning: /home/austin/.ghcup/cache/ghcup-0.0.6.yaml.tmp: Permission denied
  0  134k    0   858    0     0   8429      0  0:00:16 --:--:--  0:00:16  8495
curl: (23) Failure writing output to destination
[ Warn  ] Could not get download info, trying cached version (this may not be recent!)
[ ...   ] If this problem persists, consider switching downloader via: 
[ ...   ]     ghcup config set downloader Wget
[ Error ] JSON decoding failed with: YAML exception:
[ ...   ] Yaml file not found: /home/austin/.ghcup/cache/ghcup-0.0.6.yaml
[ ...   ] Consider removing /home/austin/.ghcup/cache/ghcup-0.0.6.yaml manually.
[ ...   ] 
"_eghcup upgrade" failed!

Would love an explanation as to what's happening and how to resolve it so I can start learning Haskell! Thanks in advance.

1

There are 1 best solutions below

0
On

Solved:

Turns out the snap version of curl is semi-broken. I got a successful ghcup install after running:

sudo snap remove curl

sudo apt install curl