How do I fix this error when tring to install ghc from ghcub?

Here is the error message:

[ Info  ] Merging file tree from "C:\ghcup\tmp\ghcup-d5bf0fe7341a" to "C:\ghcup\ghc\8.10.7"

[ Warn  ] Couldn't remove build dir C:\ghcup\tmp\ghcup-d5bf0fe734as: C:\ghcup\tmp\ghcup-d5bf0fe7341a01bc\ghc-8.10.7\mingw\x86_64-wgcrt0.o: removePathForcibly:removePathForcibly:removePathForciblyibly:removePathForcibly:removePathForcibly:DeleteFile "\\\\?\\C:\cup-d5bf0fe7341a01bc\\ghc-8.10.7\\mingw\\x86_64-w64-mingw32\\lib\ission denied (The process cannot access the file because it is being used by another process.)

[ Error ] Failed to merge file tree from C:\ghcup\tmp\ghcup-d5bf0-8.10.7 to C:\ghcup\ghc\8.10.7

[ ...   ] exception was: MoveFile "C:\\ghcup\\tmp\\ghcup-d5bf0fe7.10.7\\mingw\\x86_64-w64-mingw32\\lib\\binmode.o" "C:\\ghcup\\ghc\\x86_64-w64-mingw32\\lib\\binmode.o": permission denied (The process cannot access the file because it is being used by another process.)

[ ...   ] ...you may need to delete C:\ghcup\ghc\8.10.7 manually. Make sure it's gone.

[ Error ] Also check the logs in C:\ghcup\logs

I'm not sure what other process the file is being used for, I checked the logs and they say basically the same as these error messages and I tried just moving the contents of ghcup-d5bf0-8.10.7 to a folder called 8.10.7 in ghcub\ghc and I still got an error when trying to use ghci. I'm really unfamiliar with all of this, so I've just been following the instructions on Haskell.org to the letter. I am on Windows, and installed ghcup by copying the command on haskell.org/ghcup/ into PowerShell.

Update: I tried running ghcup install ghc again, and this time it seemed to successfully install. I also installed cabal and stack this way. However, running ghci still returns ghci: command not found in Git Bash. Running stack ghci returns the following:

Preparing to install GHC to an isolated location.
This will not interfere with any system-level installation.
Already downloaded.
Already downloaded.
Already downloaded.
Decompressing ghc-9.0.2.tar.xz...

7-Zip 9.20  Copyright (c) 1999-2010 Igor Pavlov  2010-11-18

Processing archive: C:\Users\arams\AppData\Local\Programs\stack\x86_64-windows\ghc-9.0.2.tar.xz

Extracting  ghc-9.0.2.tar

Everything is Ok

Size:       2890045440
Compressed: 487700912
Extracting ghc-9.0.2.tar...
Extracted total of 2989 files from ghc-9.0.2.tar
Problem while decompressing C:\Users\arams\AppData\Local\Programs\stack\x86_64-windows\ghc-9.0.2-tmp-56673b68e065083a\ghc-9.0.2.tar


  • I'm not sure what the problem actually was, but running ghcup nuke (and completely deleting everything it didn't catch), then reinstalling it by running

    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

    in PowerShell solved my problem. I recently cleared out some storage, so lack of space on my disk might have been the problem?