Detect dangling/broken shims
- Dominant language
- C#
- Stars
- 11.5k
- Forks
- 960
- PR merge metrics
- No merged PRs in 30d
Description
I've had some shims end up dangling due to uninstall issues. It's not a major issue but it can be confusing if uninstalling a package from Chocolatey and installing it elsewhere but if Chocolatey's bin wins on the path you'll see the following mildly confusing error: `Cannot find file at` ... `This usually indicates a missing or moved file.`. In this way it's easily both detected and corrected, though it might be a bit more confusing if it occurs in a script. It'd be handy if Chocolatey had a way of inspecting the shims and determining if they're still correctly targeted.
In the interim I'm using the following script filters dangling shims:
```powershell
Get-ChildItem "$env:ChocolateyInstall\bin\*.exe" | Where-Object {
(Get-Content -Encoding ascii $_) | ForEach-Object { $_ -Match 'shimgen-noop - Do not actually call the target' }
} | Where-Object {
(& $_ shimgen-noop) | ForEach-Object { If ($_ -Match 'path to executable: (.+)$') { -Not (Test-Path $Matches[1]) } }
}
```
I'm sure there's a more clever way to do it but I wanted to avoid loading the assembly and wanted to ensure that I didn't hit some issue with a shim generated from a version of `shimgen` I wasn't familiar with.
Contributor guide
Research direction
Start with the supplied PowerShell pipeline and the `shimgen-noop` output it examines, then trace how Chocolatey-generated shims are inspected. Define how the feature should report shims whose target executable no longer exists, including script-friendly output. Done means dangling or broken shims can be detected reliably without depending on an unfamiliar shim version.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, powershell
- Domain
- cli, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100