chocolatey / chocolatey/choco

An error thrown in `chocolateyBeforeModify.ps1` results in the upgrade reporting success, but Chocolatey exits -1

Open
#2,822 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

### What You Are Seeing?

When attempting to upgrade or uninstall version `1.0.0` of the `upgradepackage` test package from the repository, Chocolatey reports it was successful, but the exit code indicates failure (`-1`).

### What is Expected?

Exit code should indicate success (`0`).

### How Did You Get This To Happen? (Steps to Reproduce)

1. Run `choco install upgradepackage --version 1.0.0`
1. Run `choco upgrade upgradepackage` or `choco uninstall upgradepackage`
1. Note the output from Chocolatey is that it was successful
1. Check the output of `$LASTEXITCODE`
2. See that the code is `-1`

### System Details

* OS Build (In PowerShell run `[System.Environment]::OSVersion.version.tostring()`): Windows server 2019 used by Test Kitchen
* Windows PowerShell version (Run: `$PSVersionTable`): 5.1
* Chocolatey version (Run `choco --version`): 1.1.0

### Output Log

Chocolatey 1.1.0 output:

2022-09-20_16-19-02

Chocolatey 2.2.2 output:

![image](https://github.com/chocolatey/choco/assets/30301021/6ab03406-9d74-42b2-b309-72d73a2c0620)

Contributor guide

Open the contributing guide

Research direction

Reproduce the behavior with `choco install upgradepackage --version 1.0.0`, followed by upgrade or uninstall, and compare the reported result with `$LASTEXITCODE`. Trace how errors from the `chocolateyBeforeModify.ps1` lifecycle script are handled during these operations. Done means the command reports failure consistently and returns the expected nonzero exit code.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.