Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't find choco.exe after upgrading Chocolatey CLI using the MSI #3286

Closed
5 tasks done
o-l-a-v opened this issue Jul 28, 2023 · 6 comments · Fixed by #3290
Closed
5 tasks done

Can't find choco.exe after upgrading Chocolatey CLI using the MSI #3286

o-l-a-v opened this issue Jul 28, 2023 · 6 comments · Fixed by #3290

Comments

@o-l-a-v
Copy link

o-l-a-v commented Jul 28, 2023

Checklist

  • I have verified this is the correct repository for opening this issue.
  • I have verified no other issues exist related to my problem.
  • I have verified this is not an issue for a specific package.
  • I have verified this issue is not security related.
  • I confirm I am using official, and not unofficial, or modified, Chocolatey products.

What You Are Seeing?

Seems upgrading Chocolatey with MSI breaks Chocolatey.

Installing Chocolatey with MSI using Winget => choco outdated from CMD works fine.

  • winget install --silent --id Chocolatey.Chocolatey --version 2.1.0

Upgrading Chocolatey with MSI using Winget => choco outdated from CMD gives Cannot find file at '../choco.exe' (C:\ProgramData\chocolatey\choco.exe). This usually indicates a missing or moved file..

  • winget upgrade --silent --id Chocolatey.Chocolatey

What is Expected?

Chocolatey example command choco outdated should work just fine after upgrading Chocolatey with Winget / MSI.

How Did You Get This To Happen?

Start fresh

Uninstall Chocolatey if present. Manually remove the directory %ProgramData%\chocolatey and environment variable ChocolateyLastPathUpdate which the MSI uninstaller leaves behind. And remove %ProgramData%\chocolatey\bin from the PATH environment variable.

Install a version of Chocolatey that can be upgraded.

C:\Windows\System32>winget install --silent --id Chocolatey.Chocolatey --version 2.1.0
Found Chocolatey [Chocolatey.Chocolatey] Version 2.1.0
This application is licensed to you by its owner.
Microsoft is not responsible for, nor does it grant any licenses to, third-party packages.
Downloading https://github.com/chocolatey/choco/releases/download/2.1.0/chocolatey-2.1.0.0.msi
  ██████████████████████████████  5.84 MB / 5.84 MB
Successfully verified installer hash
Starting package install...
Successfully installed

C:\Windows\System32>

From Winget logs I see that chocolatey-2.1.0.0.msi was installed with /quiet /norestart.

%ProgramData%\chocolatey after installer is done.

image

Test that choco works from CMD

Open a new CMD window, to get the changes in environmental variables after the installer finished.

PS C:\Users\olav.birkeland> choco outdated
Chocolatey v2.1.0
2 validations performed. 1 success(es), 1 warning(s), and 0 error(s).

Validation Warnings:
 - A pending system reboot request has been detected, however, this is
   being ignored due to the current command being used 'outdated'.
   It is recommended that you reboot at your earliest convenience.

Outdated Packages
 Output is package name | current version | available version | pinned?

chocolatey|2.1.0|2.2.0|false

Chocolatey has determined 1 package(s) are outdated.
PS C:\Users\olav.birkeland>

Upgrade Chocolatey with Winget

C:\Windows\System32>winget upgrade --silent --id Chocolatey.Chocolatey
Found Chocolatey [Chocolatey.Chocolatey] Version 2.2.0.0
This application is licensed to you by its owner.
Microsoft is not responsible for, nor does it grant any licenses to, third-party packages.
Downloading https://github.com/chocolatey/choco/releases/download/2.2.0/chocolatey-2.2.0.0.msi
  ██████████████████████████████  5.85 MB / 5.85 MB
Successfully verified installer hash
Starting package install...
Successfully installed

C:\Windows\System32>

From Winget logs I see that chocolatey-2.2.0.0.msi was installed with /quiet /norestart.

%ProgramData%\chocolatey after installer is done:

image

Test that choco works from CMD

Open a new CMD

PS C:\Users\olav.birkeland> choco outdated
Cannot find file at '../choco.exe' (C:\ProgramData\chocolatey\choco.exe). This usually indicates a missing or moved file.
PS C:\Users\olav.birkeland>

System Details

  • Operating System: 10.0.22621.0
  • Windows PowerShell version: Not applicable.
  • Chocolatey CLI Version: 2.1.0.0 to 2.2.0.0
  • Chocolatey Licensed Extension version:
  • Chocolatey License type:
  • Terminal/Emulator: cmd.exe, powershell.exe

Installed Packages

Not relevant.

Output Log

Not relevant.

Additional Context

No response

@o-l-a-v o-l-a-v added the Bug label Jul 28, 2023
@pauby
Copy link
Member

pauby commented Jul 28, 2023

The Chocolatey CLI MSI is for install only. Upgrades are not supported.

The expectation is that you use the MSI to install Chocolatey CLI and then use Chocolatey CLI to upgrade Chocolatey CLI.

@o-l-a-v
Copy link
Author

o-l-a-v commented Jul 28, 2023

Fair enough. But installing v2.2.0.0 over v2.1.0.0 should then either fail (exitcode != 0), or at least not break Chocolatey, don't you agree?

@pauby
Copy link
Member

pauby commented Jul 28, 2023

I was about to update that previous comment when you replied 😄

I was going to say 'But those missing files doesn't seem right'.

@o-l-a-v
Copy link
Author

o-l-a-v commented Jul 28, 2023

Ah, yeah I agree. :) It's easy to reproduce, either with Winget or msiexec directly, so it's hopefully possible to figure out what happens.

Winget has no way to tell it that a package is not upgradable (as in a whether a newer version can be installed over an older version), as far as I know. I'll create an issue over at winget-cli to discuss that with them.

@pauby
Copy link
Member

pauby commented Jul 28, 2023

I confirm those files are missing on the upgrade from 2.1.0 to 2.2.0. The problem also appears going from 2.0.0 to 2.1.0 so this isn't new behaviour.

corbob added a commit to corbob/choco that referenced this issue Jul 31, 2023
The MSI previously included logic to remove *some* Chocolatey files.
This would leave Chocolatey in a broken state, but not actually removed.
This commit removes the entries from the MSI, so an "uninstall" of the
MSI is merely a removal of the installer's entry from Add/Remove
Programs.
corbob added a commit to corbob/choco that referenced this issue Jul 31, 2023
Currently it's not possible to upgrade Chocolatey with the MSI. This
commit adds functionality to the MSI that will error instead of blindly
allowing an upgrade that doesn't do anything.
corbob added a commit to corbob/choco that referenced this issue Aug 2, 2023
The MSI previously included logic to remove *some* Chocolatey files.
This would leave Chocolatey in a broken state, but not actually removed.
This commit removes the entries from the MSI, so an "uninstall" of the
MSI is merely a removal of the installer's entry from Add/Remove
Programs.
corbob added a commit to corbob/choco that referenced this issue Aug 2, 2023
Currently it's not possible to upgrade Chocolatey with the MSI. This
commit adds functionality to the MSI that will error instead of blindly
allowing an upgrade that doesn't do anything.
@AdmiringWorm AdmiringWorm added this to the 2.2.1 milestone Aug 2, 2023
corbob added a commit to corbob/choco that referenced this issue Aug 2, 2023
corbob added a commit to corbob/choco that referenced this issue Aug 2, 2023
corbob added a commit to corbob/choco that referenced this issue Aug 2, 2023
The MSI previously included logic to remove *some* Chocolatey files.
This would leave Chocolatey in a broken state, but not actually removed.
This commit removes the entries from the MSI, so an "uninstall" of the
MSI is merely a removal of the installer's entry from Add/Remove
Programs.
corbob added a commit to corbob/choco that referenced this issue Aug 2, 2023
Currently it's not possible to upgrade Chocolatey with the MSI. This
commit adds functionality to the MSI that will error instead of blindly
allowing an upgrade that doesn't do anything.
corbob added a commit to corbob/choco that referenced this issue Aug 2, 2023
@gep13 gep13 closed this as completed Aug 3, 2023
@gep13 gep13 changed the title Can't find choco.exe from CMD after upgrading Chocolatey with MSI and /quiet /norestart Can't find choco.exe after upgrading Chocolatey with MSI Aug 3, 2023
gep13 added a commit that referenced this issue Aug 3, 2023
* hotfix/2.2.1:
  (maint) Update GitReleaseManager configuration
  (#3291) Update Chocolatey.NuGet.Client libraries to 3.4.2
  (#3286) Adjust wording of upgrade failure message
  (#3286) Prevent MSI Upgrades
  (#3286) Do not remove any files on MSI uninstall
  (#3285) Upgrade 7z to 23.01
gep13 added a commit that referenced this issue Aug 3, 2023
* master:
  (maint) Update GitReleaseManager configuration
  (#3291) Update Chocolatey.NuGet.Client libraries to 3.4.2
  (#3286) Adjust wording of upgrade failure message
  (#3286) Prevent MSI Upgrades
  (#3286) Do not remove any files on MSI uninstall
  (#3285) Upgrade 7z to 23.01
@gep13 gep13 removed the 4 - Done label Aug 3, 2023
@gep13 gep13 changed the title Can't find choco.exe after upgrading Chocolatey with MSI Can't find choco.exe after upgrading Chocolatey CLI using the MSI Aug 4, 2023
@choco-bot
Copy link

🎉 This issue has been resolved in version 2.2.1 🎉

The release is available on:

Your GitReleaseManager bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants