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

(#46) Fix issues when lock files are attempted to be written in restricted directories #47

Conversation

AdmiringWorm
Copy link
Member

Description Of Changes

THe changes in this PR are related to the changes that was made in 3.4.1.
Among these changes it corrects the location to write lock files to when a package gets extracted. It was incorrectly using the directory of a nupkg file, which caused issues when the file gets downloaded to this location as NuGet.Client attempts to clean out the directory first, which would cause a process denied exception due to the lock file being there.

Additionally, the use of the BasePath in the ConcurrentUtility has also been fixed by not using the Property that may cause an exception to occur when it is set to a restricted directory, and instead use the field that have no additional logic behind it.

Motivation and Context

To fix non-admins not being able download packages, and to fix the bug in 3.4.1 that causes certain installation operations to fail due to the incorrect folder being used for lock files.

Testing

  1. Pull down latest changes in this PR.
  2. Pull down the latest changes in Chocolatey CLI.
  3. Create a debug version of NuGet.Client and copy it over to Chocolatey CLI.
  4. (Elevated) Run choco config set cacheLocation "$env:ChocolateyInstall\choco-cache"
  5. (Elevated) Run choco install pester --version 5.3.0 (or a lower version if 5.3.0 is latest on your sources)
  6. Verify installation was successful
  7. (Elevated) Run choco upgrade pester
  8. Verify upgrade was successful
  9. (Elevated) Run choco uninstall pester
  10. Remove the directory $env:ChocolateyInstall\choco-cache\ChocolateyScratch
  11. Install latest version of Chocolatey Licensed Extension (unofficial build)
  12. (Non-Elevated) Run choco dowload pester --version 5.3.0 (or a lower version if 5.3.0 is latest on your sources)
  13. Verify the download was successful
  14. (Non-Elevated) Run choco download pester --force
  15. Verify the download was successful

Operating Systems Testing

  • Windows 10
  • Windows Server 2022

Change Types Made

  • Bug fix (non-breaking change).
  • Feature / Enhancement (non-breaking change).
  • Breaking change (fix or feature that could cause existing functionality to change).
  • Documentation changes.
  • PowerShell code changes.

Change Checklist

  • Requires a change to the documentation.
  • Documentation has been updated.
  • Tests to cover my changes, have been added.
  • All new and existing tests passed?
  • PowerShell code changes: PowerShell v2 compatibility checked?

Related Issue

Fixes #46

A couple of places in the package extractor we incorrectly uses
the target nupkg as the basis of where to store any lock files that
are related to these files.

This causes an issue due to the lock files being created in the same
directory that NuGet.Client removes all files from before downloading
the nupkg file, and causes a unauthorized exception.

Instead, this commit changes it to use the target path that will be set
to the directory instead, which causes the lock files to be created in its
parent directory.
In some rare cases the use of the BasePath property to store the
original location before overriding it will throw an exception when
this original location is not writable by the current process.

Instead, this commit changes to store the value directly from the
field with a similar name instead to prevent these exceptions from
occuring in these cases.
@AdmiringWorm AdmiringWorm self-assigned this Aug 2, 2023
@AdmiringWorm AdmiringWorm requested a review from gep13 August 2, 2023 10:31
Copy link
Member

@gep13 gep13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@gep13 gep13 merged commit d73a6a8 into hotfix/3.4.2 Aug 2, 2023
@gep13 gep13 deleted the 46-process-denied-when-deleting-lock-files-for-package-installs branch August 2, 2023 15:05
@gep13
Copy link
Member

gep13 commented Aug 2, 2023

@AdmiringWorm thanks for getting this fixed up!

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

Successfully merging this pull request may close these issues.

Process denied when deleting lock files for package installs
2 participants