haskell / haskell/cabal

Upgrading `cabal-install` fails on Windows

Open
#8,884 1 comment 0 reactions 0 assignees View on GitHub
cabal-install: cmd/install platform: windows type: bug
Dominant language
Haskell
Stars
1.7k
Forks
750
Avg merge
4d 3h
Merged PRs (30d)
28

Description

**Describe the bug**
As far as I can tell, the recommended way to update `cabal-install` is:
```
$ cabal update
$ cabal install cabal-install
```
However, this fails on Windows due to that platform's restrictions on deleting running executables:

**To Reproduce**
Steps to reproduce the behavior:

```
$ cabal v2-install cabal-install --overwrite-policy=always
Warning: Unknown/unsupported 'ghc' version detected (Cabal 3.7.0.0 supports
'ghc' version < 9.4):
C:\msys64\home\ben\ghc-9.4.4-x86_64-unknown-mingw32\bin\ghc.exe is version
9.4.4
Warning: Unknown/unsupported 'ghc' version detected (Cabal 3.7.0.0 supports
'ghc' version < 9.4):
C:\msys64\home\ben\ghc-9.4.4-x86_64-unknown-mingw32\bin\ghc.exe is version
9.4.4
Resolving dependencies...
Up to date
Copying 'cabal.exe' to 'C:\Users\ben\AppData\Roaming\cabal\bin\cabal.exe'
C:\Users\ben\AppData\Roaming\cabal\bin\cabal.exe: DeleteFile "\\\\?\\C:\\Users\\ben\\AppData\\Roaming\\cabal\\bin\\cabal.exe": permission denied (Access is denied.)
```

**Expected behavior**
A new `cabal-install` is installed.

**System information**
- Any Windows
- Any `cabal-install` and `ghc` release

**Additional context**
It's a bit unclear how best to handle this. Perhaps `cabal-install` should gain a `cabal upgrade` command, which works around this limitation by first moving the old executable out of the way?

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the Windows failure with `cabal v2-install cabal-install --overwrite-policy=always` and trace the executable replacement path used by `cabal-install`. Determine the appropriate Windows-safe upgrade behavior; done means a new `cabal-install` executable is installed successfully without the reported permission-denied error.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
cli, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.