chocolatey / chocolatey/choco

`choco new` template for uninstall script uses undefined variables

Open
#3,168 0 comments 0 reactions 0 assignees View on GitHub
0 - Triaging Bug
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?

https://github.com/chocolatey/choco/blob/370e36632670d3e3d25a874ea8175551891bca50/src/chocolatey/infrastructure.app/templates/ChocolateyUninstallTemplate.cs#L90

The `$packageName` variable doesn't exist. This might be meant to be `$env:PackageName` or `$packageArgs['PackageName']`, but this variable doesn't exist here.

### What is Expected?

Our templates should probably include usable code.

### How Did You Get This To Happen?

1. Run `choco new test`
2. Inspect the uninstall script generated

### System Details

N/A

### Installed Packages

```bash
N/A
```

### Output Log

```bash
N/A
```

### Additional Context

_No response_

Contributor guide

Open the contributing guide

Research direction

Start at src/chocolatey/infrastructure.app/templates/ChocolateyUninstallTemplate.cs around line 90 and run `choco new test` to inspect the generated uninstall script. Verify which package-name variable is available in that template context, then confirm the generated script no longer references an undefined variable and contains usable uninstall code.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, powershell
Domain
cli
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.