Skip to content

Instantly share code, notes, and snippets.

@kritzcreek
Last active June 1, 2022 08:51
Show Gist options
  • Save kritzcreek/a5221afb73e9ed35d2d8fb43ef0cebe1 to your computer and use it in GitHub Desktop.
Save kritzcreek/a5221afb73e9ed35d2d8fb43ef0cebe1 to your computer and use it in GitHub Desktop.

My latest attempt at installing and using cabal on Windows:

Installation via choco fails.

C:\WINDOWS\system32>choco install ghc --version 8.10.7
Chocolatey v0.11.2
Installing the following packages:
ghc
By installing, you accept licenses for the packages.

cabal v3.6.2.0 [Approved]
cabal package files install completed. Performing other installation steps.
Downloading cabal 64 bit
  from 'https://downloads.haskell.org/cabal/cabal-install-3.6.2.0/cabal-install-3.6.2.0-x86_64-windows.zip'
Progress: 100% - Completed download of C:\Users\creek\AppData\Local\Temp\chocolatey\cabal\3.6.2.0\cabal-install-3.6.2.0-x86_64-windows.zip (13.28 MB).
Download of cabal-install-3.6.2.0-x86_64-windows.zip (13.28 MB) completed.
Hashes match.
Extracting C:\Users\creek\AppData\Local\Temp\chocolatey\cabal\3.6.2.0\cabal-install-3.6.2.0-x86_64-windows.zip to C:\ProgramData\chocolatey\lib\cabal\tools\cabal-3.6.2.0...
C:\ProgramData\chocolatey\lib\cabal\tools\cabal-3.6.2.0
Could not read cabal configuration key 'install-method'.
Updated cabal configuration.
Adding C:\ProgramData\chocolatey\bin\mingw64-pkg.bat and pointing it to powershell command C:\ProgramData\chocolatey\lib\cabal\tools\mingw64-pkg.ps1
Environment Vars (like PATH) have changed. Close/reopen your shell to
 see the changes (or in powershell/cmd.exe just type `refreshenv`).
 ShimGen has successfully created a shim for cabal.exe
 The install of cabal was successful.
  Software installed to 'C:\ProgramData\chocolatey\lib\cabal\tools\cabal-3.6.2.0'

ghc v8.10.7 [Approved]
ghc package files install completed. Performing other installation steps.
File appears to be downloaded already. Verifying with package checksum to determine if it needs to be redownloaded.
Error - hashes do not match. Actual value was '0187969A29CB8F80E4266B933D58CB6F0CC78423778E38C52444A62ACA6546D1'.
Downloading ghc 64 bit
  from 'https://downloads.haskell.org/~ghc/8.10.7/ghc-8.10.7-x86_64-unknown-mingw32.tar.xz'
Progress: 81% - Saving 338.98 MB of 414.01 MB                                                                          ERROR: The remote file either doesn't exist, is unauthorized, or is forbidden for url 'https://downloads.haskell.org/~ghc/8.10.7/ghc-8.10.7-x86_64-unknown-mingw32.tar.xz'. Exception calling "Read" with "3" argument(s): "The decryption operation failed, see inner exception."
Error computing hash for 'C:\ProgramData\chocolatey\lib\ghc\tmp\ghcInstall'
 Hash will be special code for locked file or file too big instead.
 Captured error:
  The process cannot access the file 'C:\ProgramData\chocolatey\lib\ghc\tmp\ghcInstall' because it is being used by another process.
The install of ghc was NOT successful.
Error while running 'C:\ProgramData\chocolatey\lib\ghc\tools\chocolateyInstall.ps1'.
 See log for details.
This is try 1/3. Retrying after 300 milliseconds.
 Error converted to warning:
 (5) Access is denied: [\\?\C:\ProgramData\chocolatey\lib-bad\ghc]
This is try 2/3. Retrying after 400 milliseconds.
 Error converted to warning:
 (5) Access is denied: [\\?\C:\ProgramData\chocolatey\lib-bad\ghc]
Maximum tries of 3 reached. Throwing error.
This is try 1/3. Retrying after 300 milliseconds.
 Error converted to warning:
 (32) The process cannot access the file because it is being used by another process: [\\?\C:\ProgramData\chocolatey\lib-bad\ghc\tmp\ghcInstall]
This is try 2/3. Retrying after 400 milliseconds.
 Error converted to warning:
 (32) The process cannot access the file because it is being used by another process: [\\?\C:\ProgramData\chocolatey\lib-bad\ghc\tmp\ghcInstall]
Maximum tries of 3 reached. Throwing error.
Could not move the bad package to the failure directory. It will show as installed.
 C:\ProgramData\chocolatey\lib\ghc
 The error:
 (32) The process cannot access the file because it is being used by another process: [\\?\C:\ProgramData\chocolatey\lib-bad\ghc\tmp\ghcInstall]
This is try 1/3. Retrying after 300 milliseconds.
 Error converted to warning:
 (183) Cannot create a file when that file already exists: [\\?\C:\ProgramData\chocolatey\lib\ghc]
This is try 2/3. Retrying after 400 milliseconds.
 Error converted to warning:
 (183) Cannot create a file when that file already exists: [\\?\C:\ProgramData\chocolatey\lib\ghc]
Maximum tries of 3 reached. Throwing error.
This is try 1/3. Retrying after 300 milliseconds.
 Error converted to warning:
 (32) The process cannot access the file because it is being used by another process: [\\?\C:\ProgramData\chocolatey\lib\ghc\tmp\ghcInstall]
This is try 2/3. Retrying after 400 milliseconds.
 Error converted to warning:
 (32) The process cannot access the file because it is being used by another process: [\\?\C:\ProgramData\chocolatey\lib\ghc\tmp\ghcInstall]
Maximum tries of 3 reached. Throwing error.
ghc not installed. An error occurred during installation:
 (32) The process cannot access the file because it is being used by another process: [\\?\C:\ProgramData\chocolatey\lib\ghc\tmp\ghcInstall]
ghc package files install failed with exit code 404. Performing other installation steps.
The install of ghc was NOT successful.
Error while running 'C:\ProgramData\chocolatey\lib\ghc\tools\chocolateyInstall.ps1'.
 See log for details.
ghc not installed. An error occurred during installation:
 (32) The process cannot access the file because it is being used by another process: [\\?\C:\ProgramData\chocolatey\lib\ghc\tmp\ghcInstall]
This is try 1/3. Retrying after 300 milliseconds.
 Error converted to warning:
 (5) Access is denied: [\\?\C:\ProgramData\chocolatey\lib-bad\ghc]
This is try 2/3. Retrying after 400 milliseconds.
 Error converted to warning:
 (5) Access is denied: [\\?\C:\ProgramData\chocolatey\lib-bad\ghc]
Maximum tries of 3 reached. Throwing error.
This is try 1/3. Retrying after 300 milliseconds.
 Error converted to warning:
 (32) The process cannot access the file because it is being used by another process: [\\?\C:\ProgramData\chocolatey\lib-bad\ghc\tmp\ghcInstall]
This is try 2/3. Retrying after 400 milliseconds.
 Error converted to warning:
 (32) The process cannot access the file because it is being used by another process: [\\?\C:\ProgramData\chocolatey\lib-bad\ghc\tmp\ghcInstall]
Maximum tries of 3 reached. Throwing error.
Could not move the bad package to the failure directory. It will show as installed.
 C:\ProgramData\chocolatey\lib\ghc
 The error:
 (32) The process cannot access the file because it is being used by another process: [\\?\C:\ProgramData\chocolatey\lib-bad\ghc\tmp\ghcInstall]
This is try 1/3. Retrying after 300 milliseconds.
 Error converted to warning:
 (183) Cannot create a file when that file already exists: [\\?\C:\ProgramData\chocolatey\lib\ghc]
This is try 2/3. Retrying after 400 milliseconds.
 Error converted to warning:
 (183) Cannot create a file when that file already exists: [\\?\C:\ProgramData\chocolatey\lib\ghc]
Maximum tries of 3 reached. Throwing error.
This is try 1/3. Retrying after 300 milliseconds.
 Error converted to warning:
 (32) The process cannot access the file because it is being used by another process: [\\?\C:\ProgramData\chocolatey\lib\ghc\tmp\ghcInstall]
This is try 2/3. Retrying after 400 milliseconds.
 Error converted to warning:
 (32) The process cannot access the file because it is being used by another process: [\\?\C:\ProgramData\chocolatey\lib\ghc\tmp\ghcInstall]
Maximum tries of 3 reached. Throwing error.

Chocolatey installed 0/0 packages.
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
(32) The process cannot access the file because it is being used by another process: [\\?\C:\ProgramData\chocolatey\lib\ghc\tmp\ghcInstall]

Let's try ghcup:

  1. Copy the command from https://www.haskell.org/ghcup/
C:\Users\creek> Set-ExecutionPolicy Bypass -Scope Process -Force;[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072;Invoke-Command -ScriptBlock ([ScriptBlock]::Create((Invoke-WebRequest https://www.haskell.org/ghcup/sh/bootstrap-haskell.ps1 -UseBasicParsing))) -ArgumentList $true
Chocolatey was detected on your system. It is capable of installing the Haskell toolchain as well.
If you want to rather use that instead of ghcup, abort the installation and run the following at an
elevated command prompt:
    choco install haskell-dev
    refreshenv

Continue with GHCup installation?
[C] Continue  [A] Abort  [?] Help (default is "C"):

Well we just tried choco and it failed, so let's continue.

Picking the defaults for everything:

Picked C:\ as default Install prefix!
Where to install to (this should be a short Path, preferably a Drive like 'C:\')
Press enter to accept the default [C:\]:

Setting env variable GHCUP_INSTALL_BASE_PREFIX to 'C:\'
Preparing for GHCup installation...
Specify Cabal directory (this is where haskell packages end up)
Press enter to accept the default [C:\\cabal]:


Install HLS
Do you want to install the haskell-language-server (HLS) for development purposes as well?
[Y] Yes  [N] No  [A] Abort  [?] Help (default is "N"):

Install stack
Do you want to install stack as well?
[Y] Yes  [N] No  [A] Abort  [?] Help (default is "N"):
First checking for Msys2...

Install MSys2
Do you want GHCup to install a default MSys2 toolchain (recommended)?
[Y] Yes  [N] No  [?] Help (default is "Y"):
...Msys2 doesn't exist, installing into C:\\ghcup\msys64
Starting installation in 5 seconds, this may take a while...

Looks like ghcup is going to install Msys2 for me (like stack), which gives it at least a chance at succeeding.

10 minutes of downloading and installing things later:

...
Setting default home directory...
Creating shortcuts...
Adding C:\\ghcup\bin to Users Path...
Setting CABAL_DIR to 'C:\cabal'
Starting GHCup installer...

It opens a separate MinGW shell and dies with:

Welcome to Haskell!

This script will 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 - (optional) A cross-platform program for developing Haskell projects
  * 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:
  C:\ghcup

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 36.9M  100 36.9M    0     0  6212k      0  0:00:06  0:00:06 --:--:-- 6712k
[ Info  ] downloading: https://www.haskell.org/ghcup/data/ghcup-0.0.6.yaml as file C:/ghcup\cache\ghcup-0.0.6.yaml
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  128k  100  128k    0     0   128k      0  0:00:01  0:00:01 --:--:--  110k
[ Info  ] downloading: https://downloads.haskell.org/~ghcup/shimgen/shim-2.exe as file C:/ghcup\cache\gs.exe
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  113k  100  113k    0     0   113k      0  0:00:01 --:--:--  0:00:01  515k
[ Info  ] verifying digest of: gs.exe
[ Info  ] Upgrading GHCup...
[ Warn  ] No GHCup update available

[ Info  ] verifying digest of: gs.exe
System requirements
  Note: On Windows, msys2 should already have been set up during the installation, so most users should just press ENTER. If you are installing manually, make sure to have a working mingw64 toolchain and shell.
[ Info  ] verifying digest of: gs.exe
[ Info  ] downloading: https://downloads.haskell.org/~ghc/8.10.7/ghc-8.10.7-x86_64-unknown-mingw32.tar.xz as file C:/ghcup\cache\ghc-8.10.7-x86_64-unknown-mingw32.tar.xz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0  414M    0 2453k    0     0  2453k      0  0:02:52 --:--:--  0:02:52 5230k
curl: (56) Failure when receiving data from the peer
[ Error ] Download failed: Process "curl" with arguments ["-fL", "-o",
[ ...   ]                                                 "C:/ghcup\\cache\\ghc-8.10.7-x86_64-unknown-mingw32.tar.xz.tmp",
[ ...   ]                                                 "https://downloads.haskell.org/~ghc/8.10.7/ghc-8.10.7-x86_64-unknown-mingw32.tar.xz"] failed with exit code 56.
[ Error ] Also check the logs in C:/ghcup\logs
"_eghcup --cache install ghc recommended" failed!
cat: 'https'$'\357\200\272''/www.haskell.org/ghcup/sh/bootstrap-haskell': No such file or directory
Press any key to exit

And now I have a half broken Haskell installation with things scattered across my root C:\\ directory...

Maybe next year.

@MinglangTuo
Copy link

I have the same problem during install it. How to install Haskell Completely?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment