On windows cabal-install can't `cabal install` cabal-install.
- Dominant language
- Haskell
- Stars
- 1.7k
- Forks
- 750
- Avg merge
- 4d 3h
- Merged PRs (30d)
- 28
Description
**Describe the bug**
When using `cabal` installed by `cabal install` then cabal can't install a new `cabal` binary over the existing one on windows.
```
$ cabal install cabal-install --overwrite-policy=always -j10
Warning: this is a debug build of cabal-install with assertions enabled.
Wrote tarball sdist to
...
C:\Users\andi\repos\cabal\dist-newstyle\sdist\solver-benchmarks-3.tar.gz
Resolving dependencies...
Symlinking 'cabal.exe' to 'C:\ghcup\cabal\bin\cabal.exe'
C:\ghcup\cabal\bin\cabal.exe: DeleteFile "\\\\?\\C:\\ghcup\\cabal\\bin\\cabal.exe": permission denied (Access is denied.)
While handling DeleteFile "\\\\?\\C:\\ghcup\\cabal\\bin\\cabal.exe": permission denied (Access is denied.)
```
I don't think this ever worked, but it would be really nice if it did! The reason is obvious. Windows doesn't allow deletion of opened filed. Which includes running executables.
For this to work cabal would need to rename the existing cabal binary, install the new one. And delete the old one on the next cabal invocation I suppose. Perhaps that is too fiddly.After all I do recognize I'm in the minority installing cabal via `cabal-install`.
But something slightly more user friendly like a error saying:
```
Failed to install executable `cabal.exe` you might try installing it into the cabal bin folder manually with
cp
```
Would be nice. `cp` with just two paths works both in power shell and msys/linux too so not much need to special case that either.
Contributor guide
Research direction
The payload names no files or tests. Reproduce `cabal install cabal-install --overwrite-policy=always -j10` on Windows, then trace the executable replacement path and its handling of `DeleteFile` permission errors. Done means the command either replaces the running executable safely or reports a clear, actionable installation error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- haskell
- Domain
- build-system, cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 50/100