Devolutions / Devolutions/UniGetUI
[BUG] Updating cargo-binstall through UniGetUI can never succeed on Windows (binary replaces itself)
- Dominant language
- C#
- Stars
- 26.1k
- Forks
- 924
- Avg merge
- 15h 52m
- Merged PRs (30d)
- 52
Description
### Please confirm these before moving forward
- [x] I have searched for my issue and have not found a work-in-progress/duplicate/resolved issue.
- [x] I have tested that this issue has not been fixed in the latest (beta or stable) release.
- [x] I have checked the FAQ section for solutions.
- [x] This issue is about a bug.
### UniGetUI Version
2026.2.7 (latest stable)
### Windows version, edition, and architecture
Windows 11 Pro 10.0.26200 x64
### Describe your issue
Updating the **`cargo-binstall`** package itself through UniGetUI (Cargo manager) can never succeed on Windows.
When `cargo-binstall` is present, UniGetUI runs every Cargo update as:
```
cargo.exe binstall --no-confirm
```
(`CargoPkgOperationHelper._getOperationParameters`, `OperationType.Update` branch, `UpdateVerb = "binstall"` in `Cargo.cs`).
For the package `cargo-binstall` this means the running `cargo-binstall.exe` is asked to overwrite **itself**. `cargo-binstall` handles that case only when it downloads a prebuilt binary (upstream fix cargo-bins/cargo-binstall#712 for #702). When its fetchers time out and it falls back to `cargo install cargo-binstall` ("will be installed from source (with cargo)"), the fallback simply shells out to `cargo install`, which compiles for ~3 minutes and then fails to replace the locked executable:
```
Replacing C:\Users\\.cargo\bin\cargo-binstall.exe
error: failed to move `C:\Users\\.cargo\bin\cargo-installAeQfV8\cargo-binstall.exe` to `C:\Users\\.cargo\bin\cargo-binstall.exe`
Caused by:
Access is denied. (os error 5)
ERROR Cargo errored! ExitStatus(ExitStatus(101))
```
Windows does not allow a running .exe to be replaced, so this path can never work. Every attempt leaves the old version installed, UniGetUI keeps listing `cargo-binstall` as updatable, and each retry costs a full source build. Stale `cargo-binstall.exe~RF*.TMP` files are also left behind in `%USERPROFILE%\.cargo\bin`.
Upstream tracks self-replace for the remaining cases in cargo-bins/cargo-binstall#1066 (open since 2023), so UniGetUI should not rely on `cargo binstall cargo-binstall` for this package.
**Suggested fix**
Special-case `package.Id == "cargo-binstall"` in `CargoPkgOperationHelper` and update it without going through the running binary, e.g.:
```
cargo.exe install cargo-binstall --locked --force
```
`cargo.exe` is a different file, so it can replace `cargo-binstall.exe` without a lock conflict. This is also the exact command `Cargo.cs` already uses as the binstall dependency installer (`"cargo install cargo-binstall --locked"`), so the code path exists.
### Steps to reproduce the issue
1. Windows, `cargo-binstall` installed in `%USERPROFILE%\.cargo\bin` (as installed by UniGetUI's dependency prompt).
2. Wait until a newer `cargo-binstall` release exists (here: 1.19.0 -> 1.23.0).
3. In UniGetUI, Software Updates -> update "Cargo Binstall".
4. Update fails with exit code 70 after the source build; the installed version is unchanged.
Reproduced on 2026-08-16 (1.21.1) and 2026-09-11 (1.23.0). Manual workaround that works: `cargo install cargo-binstall --locked --force` from a terminal, or the official `install-from-binstall-release.ps1` script.
### UniGetUI Log
```text
Package update operation for Package=cargo-binstall with Manager=Cargo
Update options:
Version: 1.19.0 -> 1.23.0
Executing process with StartInfo:
- FileName: "C:\Program Files\UniGetUI\Assets\Utilities\UniGetUI Elevator.exe"
- Arguments: ""C:\Users\\.cargo\bin\cargo.exe" binstall cargo-binstall --no-confirm"
Start Time: "11.09.2026 17:35:20"
INFO resolve: Resolving package: 'cargo-binstall'
WARN resolve: Timeout reached while checking fetcher invalid url: deadline has elapsed
(repeated x9)
WARN resolve: Timeout reached while checking fetcher QuickInstall: deadline has elapsed
(repeated x9)
WARN The package cargo-binstall v1.23.0 will be installed from source (with cargo)
Updating crates.io index
Downloading crates ...
Downloaded cargo-binstall v1.23.0
Installing cargo-binstall v1.23.0
Locking 544 packages to latest compatible versions
...
error: failed to compile `cargo-binstall v1.23.0`, intermediate artifacts can be found at `C:\Users\\AppData\Local\Temp\cargo-installiTKvt6`.
ERROR Cargo errored! ExitStatus(ExitStatus(101))
ERROR Fatal error:
x For crate cargo-binstall: subprocess C:\Users\\.rustup\toolchains\stable-x86_64-pc-windows-msvc\bin\cargo.exe install cargo-binstall --version 1.23.0 --root C:\Users\\.cargo errored with exit code: 101
```
Operation history: Status=failed, ExitCode=70, "Cargo Binstall could not be updated".
### Package Managers Logs
```text
Same command run manually in a terminal (cargo binstall cargo-binstall) shows the underlying cause after the build finishes:
Compiling binstalk-fetchers v0.10.48
Compiling binstalk-registry v0.12.8
Compiling binstalk v0.28.81
Finished `release` profile [optimized] target(s) in 2m 53s
Replacing C:\Users\\.cargo\bin\cargo-binstall.exe
error: failed to move `C:\Users\\.cargo\bin\cargo-installAeQfV8\cargo-binstall.exe` to `C:\Users\\.cargo\bin\cargo-binstall.exe`
Caused by:
Access is denied. (os error 5)
ERROR Cargo errored! ExitStatus(ExitStatus(101))
ERROR Fatal error:
x For crate cargo-binstall: subprocess ...\cargo.exe install cargo-binstall --version 1.23.0 --root C:\Users\\.cargo errored with exit code: 101
```
### Relevant information
- rustc 1.98.1 / cargo 1.98.1, stable-x86_64-pc-windows-msvc
- cargo-binstall 1.19.0 installed (not a symlink; plain .exe in `.cargo\bin`)
- Update was run with "Run as administrator" enabled (UniGetUI Elevator).
- Related upstream: cargo-bins/cargo-binstall#702 (closed, prebuilt path only), #712, #1066 (open: use self-replace when self-updating).
Contributor guide
Research direction
Start in CargoPkgOperationHelper, especially _getOperationParameters and the OperationType.Update branch, then review the related Cargo.cs dependency-install command. Reproduce the cargo-binstall update path on Windows and verify that the update no longer invokes the running binary and that the installed version changes successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, rust
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 76/100