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

Chocolatey CLI is unable to save HTTP Cache files when running as a non-admin user and the cachelocation is set to point at the Chocolatey ProgramData folder #3264

Closed
3 tasks
gep13 opened this issue Jul 13, 2023 · 2 comments · Fixed by #3279
Assignees
Labels
5 - Released Bug Requires NuGet.Client Change This issue requires a modification to something in referenced NuGet.Client library.
Milestone

Comments

@gep13
Copy link
Member

gep13 commented Jul 13, 2023

What You Are Seeing?

The problem that is being described here was first witnessed when running Chocolatey GUI in self-service mode, after running the standard ClientSetup.ps1 file. This file includes a change to the cacheLocation configuration value, to point it at a choco-cache folder within Chocolatey's ProgramData folder. What follows is the original content of the issue that was raised, but the ultimate fix to this problem will be a change to the Chocolatey.NuGet.Client libraries, to change where the lock file is created, when the cacheLocation has been set to a location that a non-admin user doesn't have access to.

Original Issue Content

When Chocolatey GUI is opened in a non-admin user account and a V2 feed source is selected, it is unable to fetch packages from a V2 feed, throws an Unhandled Exception, and then crashes.

When Chocolatey GUI is opened in an admin user account and a source is selected, there is no issue.

When Chocolatey GUI is opened in a non-admin user account and a V3 feed source is selected, it does not throw the Unhandled Exception, but it will hang for nearly an hour trying to read the source, and then fails with No Packages Found.

What is Expected?

Selecting a source with either a V2 or V3 feed should present the packages within that source for viewing and interaction.

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

V2 Feed

  1. Open Chocolatey GUI as a non-admin user.
  2. Select the source (I used ChocolateyInternal with a V2 feed)
  3. Chocolatey GUI throws an error stating that it failed to find packages on a V2 feed, throws the Unhandled Exception, then crashes.

V3 Feed

  1. Open Chocolatey GUI as a non-admin user.
  2. Select the source (I used ChocolateyInternal with a V3 feed)
  3. Chocolatey GUI hung at reading the source for nearly an hour then failed with No Packages Found.

Full Reproduction Steps

  1. Installed Chocolatey CLI 2.1.0
  2. Ran choco config set --name="'cacheLocation'" --value="'c:\programdata\chocolatey\choco-cache'"
  3. Create a new non-admin user on the computer
  4. Logged out as administrator and logged in as the non-admin user
  5. Ran the command choco outdated

System Details

  • Operating System: Windows 11
  • Windows PowerShell Version: 5.1
  • Chocolatey CLI Version: 2.1.0
  • Chocolatey Licensed Extension version: 6.1.0
  • Chocolatey License type (Professional / Business / ?): Business Trial
  • Terminal/Emulator:

Verification Images

image

image

image

Workarounds

  1. Change the cacheLocation to somewhere that everyone has access to. Ideally, run choco config unset --name="'cacheLocation'", which will set it back to the default TEMP folder location which everyone has access to.
  2. Add outdated to the list of list of backgroundServiceAllowedCommands i.e. choco config set --name="'backgroundServiceAllowedCommands'" --value="',outdated'" If you go this route, likely searching within the Chocolatey GUI application will still be broken
  3. Revert to an earlier version of Chocolatey products.

Proposed Solution

A change will be needed to the Chocolatey.NuGet.Client libraries to allow the usage of another folder, that isn't the TEMP folder, for the creation of the lock files that are needed when writing HTTP Cache files to disk. This will mean that the writing of the lock files will not be dependent on the changes to the TEMP environment variable, which happens when the user sets the cacheLocation value.

Related Issues and Tickets

Zendesk Ticket 18559

Zendesk Ticket 18560

Zendesk Ticket 18651

Zendesk Ticket 18676

Done Checklist

  • Documentation has been updated.
  • Automated tests have been added to cover this bug.
  • Manual tests have been added to cover this bug.
@gep13 gep13 added this to the 2.2.0 milestone Jul 13, 2023
@gep13 gep13 self-assigned this Jul 13, 2023
@gep13
Copy link
Member Author

gep13 commented Jul 13, 2023

Further discussion was had on this issue in the internal ticket here: https://gitlab.com/chocolatey/solutions/support-issues/-/issues/33

@gep13 gep13 added the Requires NuGet.Client Change This issue requires a modification to something in referenced NuGet.Client library. label Jul 14, 2023
AdmiringWorm added a commit to AdmiringWorm/choco that referenced this issue Jul 24, 2023
As part of the changes that is coming in our custom flavor
of NuGet.Client, the cache directories will now contain the
a new folder where lock files are located when issuing
HTTP requests.

The cache command needs to ignore these directories as
they may contain locked files that can not be cleaned up,
and is not part of the cached HTTP queries.
gep13 added a commit to AdmiringWorm/choco that referenced this issue Jul 24, 2023
Start using 3.4.0, which includes a fix for a bug where saving of a
lock file, used when creating a HTTP cache file, was not allowed due to
invalid permissions.
@gep13 gep13 linked a pull request Jul 25, 2023 that will close this issue
10 tasks
gep13 pushed a commit to AdmiringWorm/choco that referenced this issue Jul 25, 2023
As part of the changes that is coming in our custom flavor
of NuGet.Client, the cache directories will now contain the
a new folder where lock files are located when issuing
HTTP requests.

The cache command needs to ignore these directories as
they may contain locked files that can not be cleaned up,
and is not part of the cached HTTP queries.
gep13 added a commit to AdmiringWorm/choco that referenced this issue Jul 25, 2023
Start using 3.4.0, which includes a fix for a bug where saving of a
lock file, used when creating a HTTP cache file, was not allowed due to
invalid permissions.
gep13 added a commit that referenced this issue Jul 25, 2023
(#3264) Ignore lock folders in cache directories
@gep13 gep13 added 4 - Done and removed 3 - Review labels Jul 25, 2023
@gep13 gep13 changed the title Unable to save HTTP Cache files when running as non-admin user when cacheLocation is set to point at Chocolatey ProgramData folder Chocolatey CLI is unable to save HTTP Cache files when running as a non-admin user and the cacheLocation is set to point at the Chocolatey ProgramData folder Jul 26, 2023
gep13 added a commit that referenced this issue Jul 26, 2023
* release/2.2.0: (21 commits)
  (doc) Update to indicate new package version used
  (maint) Add helper to split on max line lengths
  (#3281) Add validation for cache folder permissions
  (#3264) Update to latest Chocolatey.NuGet.Client
  (#3264) Ignore lock folders in cache directories
  (#3186) Remove easter egg
  (doc) Improve error message for defaultPushSource
  (tests) Clear HTTP Cache before getting packages
  (#3258) Expand logging for nuget resources errors
  (maint) Set file encoding to include BOM
  (#3237) Reduce number of queries for dependencies
  (#3231) Add tests to ensure package listing
  (maint) Remove unnecessary using statements
  (#3231) Don't refresh local package info during upgrade no-ops
  (build) Update to latest recipe package
  (doc) Minor corrections to wording
  (#3242) Add a script to run Authenticated tests
  (#3242) Attempt default credentials for sources
  (maint) Fix incorrect naming style uses
  (doc) Apply scripting best practices to output
  ...
@choco-bot
Copy link

🎉 This issue has been resolved in version 2.2.0 🎉

The release is available on:

Your GitReleaseManager bot 📦🚀

@gep13 gep13 changed the title Chocolatey CLI is unable to save HTTP Cache files when running as a non-admin user and the cacheLocation is set to point at the Chocolatey ProgramData folder Chocolatey CLI is unable to save HTTP Cache files when running as a non-admin user and the cachelocation is set to point at the Chocolatey ProgramData folder Aug 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
5 - Released Bug Requires NuGet.Client Change This issue requires a modification to something in referenced NuGet.Client library.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants