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

chocolateybeforemodify runs after modifying (moving) chocolatey lib package files #995

Closed
bcurran3 opened this issue Oct 2, 2016 · 1 comment
Assignees
Milestone

Comments

@bcurran3
Copy link

bcurran3 commented Oct 2, 2016

linkback: https://groups.google.com/forum/#!topic/chocolatey/mrVxXzgyi2Y

chocolateybeforemodify.ps1 runs after backing up Chocolatey lib files, causing some unnecessary errors to occur when files are open. Changing it to run before the backup of the files will prevent this

example package: torchat

So I decided to do my first package utilizing chocolateybeforemodify.ps1 (Which I think is a great idea, but a non-intuitive filename.)

I moved my Stop-Process -processname stuff into chocolateybeforemodify.ps1 and my chocolateyuninstall.ps1 only has some Remove-Item commands to delete shortcuts.

It didn't make a difference; the directory still tried to be removed before chocolateybeforemodify.ps1 ran.

Here's the results:
C:\ChocolateyPackages\torchat>choco uninstall torchat
Chocolatey v0.10.2
Uninstalling the following packages:
torchat
This is try 1/3. Retrying after 300 milliseconds. <- this is because the program EXE is still running.
Error converted to warning:
(5) Access is denied: [?\C:\ProgramData\chocolatey\lib-bkp\torchat]
This is try 2/3. Retrying after 400 milliseconds.
Error converted to warning:
(5) Access is denied: [?\C:\ProgramData\chocolatey\lib-bkp\torchat]
Maximum tries of 3 reached. Throwing error.
This is try 1/3. Retrying after 300 milliseconds.
Error converted to warning:
(32) The process cannot access the file because it is being used by another process: [?\C:\ProgramData\chocolatey\lib-bkp\torchat\tools\bin\torchat.exe]
This is try 2/3. Retrying after 400 milliseconds.
Error converted to warning:
(32) The process cannot access the file because it is being used by another process: [?\C:\ProgramData\chocolatey\lib-bkp\torchat\tools\bin\torchat.exe]
Maximum tries of 3 reached. Throwing error.
Error during backup (move phase):
(32) The process cannot access the file because it is being used by another process: [?\C:\ProgramData\chocolatey\lib-bkp\torchat\tools\bin\torchat.exe]
There was an error accessing files. This could mean there is a
process locking the folder or files. Please make sure nothing is
running that would lock the files or folders in this directory prior
to upgrade. If the package fails to upgrade, this is likely the cause.

torchat v0.9.9.553 <- start of chocolateybeforemodify.ps1
Stopping tor process...
Stopping torchat process...
Skipping auto uninstaller - No registry snapshot. <- start of chocolateyuninstall.ps1
torchat has been successfully uninstalled.

Chocolatey uninstalled 1/1 packages. 0 packages failed.
See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).

@ferventcoder
Copy link
Member

This will be released in 0.10.3

ferventcoder added a commit that referenced this issue Oct 5, 2016
This is really before upgrade or uninstall, so it should be named
appropriately.
ferventcoder added a commit that referenced this issue Oct 5, 2016
For upgrades and uninstalls, there was an attempt to run other
operations ahead of the beforeModify script, which included removing a
rollback directory that may have been locking files for a service.
Instead ensure that before modify is the first physcial operation
attempted prior to upgrades and uninstall actions.

For uninstalls, ensure that the before modify action is passed through
as part of the actions to take prior to uninstall instead of waiting
for the regular means to come back to handle_package_uninstall.
ferventcoder added a commit to ferventcoder/choco that referenced this issue Oct 5, 2016
* stable:
  (chocolateyGH-1000) Allow `$LASTEXITCODE` check by feature
  (chocolateyGH-1000) Don't check $LASTEXITCODE by default
  (chocolateyGH-995) Ensure beforeModify runs as first action
  (maint) specs fixup
  (chocolateyGH-996) ISourceRunner.uninstall beforeModify action
  (chocolateyGH-996) beforemodify check before run
  (chocolateyGH-995) rename before_package_upgrade
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants