chocolatey / chocolatey/choco

Automatically created shims should be removed during upgrade

Open
#3,206 2 comments 0 reactions 1 assignee Claimed by @AdmiringWorm View on GitHub
1 - Ready ClickUp - Backlog Enhancement
Dominant language
C#
Stars
11.5k
Forks
960
PR merge metrics
No merged PRs in 30d

Description

### Checklist

- [X] I have verified this is the correct repository for opening this issue.
- [X] I have verified no other issues exist related to my problem.
- [X] I have verified this is not an issue for a specific package.
- [X] I have verified this issue is not security related.

### What You Are Seeing?

When upgrading a package that previously relied on automatically created shims, but a new version no longer have an executable in the directory in the end of the execution the shims are still present due to them never being removed automatically on upgrades, unlike what is happening when uninstalling a package.

This semi-worked previously in pre-v2 version of Chocolatey CLI as it would not completely clean the directory of the previous package on upgrades which would leave the old executables in the directory and still implying that the shim works (just for the old version).

Now that Chocolatey CLI v2 completely cleans the directory, it is quickly found when such shims do not work anymore. As such we should delete these shims on upgrade (possibly right after creating a backup of the directory).

### What is Expected?

Shims for old versions of a package automatically created by Chocolatey CLI should not be present after upgrading a package.

### How Did You Get This To Happen?

The easiest way to find this issue, is with the starship package available on Chocolatey CLI.

1. Install version 1.11.0 of starship `choco install starship --version 1.11.0`
2. Upgrade this package using `choco upgrade starship`
3. Notice `%ChocolateyInstall%\bin\starship.exe` still exists
4. Notice `%ChocolateyInstall%\lib\starship\tools\starship.exe` does not exist (it will exist on pre-v2).

### System Details

* Operating System: Windows Server 2022 (10.0.20348.0)
* Windows PowerShell version: 5.1.20348.859
* Chocolatey CLI Version: 2.0.0
* Chocolatey Licensed Extension version: N/A
* Chocolatey License type: N/A
* Terminal/Emulator: Windows PowerShell

### Installed Packages

```bash
After Upgrade:

chocolatey 2.0.0
starship 1.15.0
starship.install 1.15.0
```

### Output Log

```bash
https://gist.github.com/AdmiringWorm/f6d2a40dc9b7be9131369b55d44d424e
```

### Additional Context

_No response_

┆Issue is synchronized with this [Clickup task](https://app.clickup.com/t/868j271rt) by [Unito](https://www.unito.io)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.