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

Correctly handle SIGINT / Control+C #619

Open
3 tasks
alexchandel opened this issue Feb 9, 2016 · 18 comments
Open
3 tasks

Correctly handle SIGINT / Control+C #619

alexchandel opened this issue Feb 9, 2016 · 18 comments

Comments

@alexchandel
Copy link

alexchandel commented Feb 9, 2016

Chocolatey currently prints the following hostile message when interrupted with Control+C:

Exiting chocolatey abnormally. Please manually clean up anything that was not finished.
Please do not ever use Control+C or close the window to exit.

But Control+C is often necessary. For example, for poor various reasons, choco list still lists every package on chocolatey. If you're on VM, or a slow connection, or in a subnet without internet, an accidental choco list can consume substantial time and must be interrupted.

Instead of doing this, why not simply handle the interrupt? On the first Control-C, Homebrew will silently begin to stop its tasks. On the second, it prints the message Just a moment, cleaning up.... And on the third Control-C, it immediately halts its tasks.

Tasks

Additional Information

Zendesk Ticket

@ferventcoder
Copy link
Member

But Control+C is often necessary. For example, for poor reasons, choco list lists every package on chocolatey.

I take a big issue with the statement "poor reasons". It sounds a bit negative, but I don't see anything on the issue you linked where the reasoning is stated for the current behavior.

It was an inherited choice from the way that NuGet worked, so we emulated the behavior. We've realized that it is incorrect and have defined the boundary where this change will occur. It does take a major version boundary to adjust it for reasons you may not understand if you have not supported a large number of users in a software development project before.

@ferventcoder
Copy link
Member

For the issue at hand, I often use Control+C, without it corrupting anything. What version of choco are you running?

@rismoney
Copy link
Contributor

rismoney commented Feb 9, 2016

I take a big issue with the statement "poor reasons".

nod. i added -lo in the original chocolatey powershell product to improve it at a time when noone was using choco in the enterprise. Those and many other community driven contributions, whether good or bad (being judged now with 20/20 hindsight) have led to worldwide chocolatey adoption and usage. This has been quite a feat given the usage of open source in the windows world.

Can things be improved, yes but improvements need not be promoted with negativity.

So you know, to compare with other package managers:
yum:

yum list will list all packages in all repositories AND all packages on your system. #same accident here
yum list installed is required to see just is on your system
yum list available etc

apt-cache may handle it more intelligently but these types of features have to be added without breakage. for instance enterprise config management systems rely on functionality in the choco product, that will break if version change is not well coordinated. Those config mgmt systems, in addition need to maintain backward compatibility too w/ choco since everyone doesn't just upgrade big bang overnight.

@alexchandel
Copy link
Author

Granted. I still hugely favor the brew approach. pacman -Q got it right too.

But for the issue at hand, it's version 0.9.9.11. I usually have no problems with Control+C, except for the most recent time when it blew up on me. I think handling it and attempting to provide orderly termination would greatly improve the user experience.

@ferventcoder
Copy link
Member

Yes I agree. The chances of corrupting the xml file are very slight in 0.9.9.11. Handling control+c differently when this file is being edited would be hugely beneficial.

@alexchandel
Copy link
Author

@ferventcoder What about handling it everywhere? This would prevent partial/broken installs if it's sent once during installation (permitting Chocolatey to roll back the installation).

@pyhedgehog
Copy link

👍 on that.

@pyhedgehog
Copy link

It would be very good to also make choco concurrent-safe. At least read-only operations should not break installations. I.e. while I'm installing or upgrading some packages I should be able to use choco outdated.

@ferventcoder
Copy link
Member

It would be very good to also make choco concurrent-safe. At least read-only operations should not break installations. I.e. while I'm installing or upgrading some packages I should be able to use choco outdated.

@pyhedgehog you mean be able to run some commands without pending? The problem here is that non-local search is pretty much the only thing aside from help you could run.

  • choco outdated could provide stale information for something that wasn't installed properly and needs to be removed.
  • choco list -lo would provide information that is out of date.
  • you shouldn't run multiple installs/upgrades at the same time either - that's more a Windows necessity over a Chocolatey need.

We are discussing this at #683

@ferventcoder
Copy link
Member

Related to #198 / #822

@pyhedgehog
Copy link

pyhedgehog commented Aug 9, 2016

that's more a Windows necessity over a Chocolatey need.

Not sure - nothing stops me from downloading several files, also nothing stops me from unpacking several zip files in parallel.

@ferventcoder
Copy link
Member

ferventcoder commented Aug 9, 2016

@pyhedgehog apologies, was referring to native installers

@pyhedgehog
Copy link

"Native" cygwin installer can be run in parallel with any other.

@Odepax
Copy link

Odepax commented Aug 12, 2016

+1 for Ctrl + C

@alexchandel
Copy link
Author

Handling SIGINT/Ctrl+C should be done in three stages:

  1. On the first Ctrl+C, chocolatey should immediately begin abandoning what it's trying to do (cancel downloads, cancel file moves, attempted installations) and roll back the partially installed package it's currently working on.
  2. On the second, it should print a message like "Working, just a moment..." to let the user know it hasn't hung.
  3. On the third, it should give up and abort.

@ferventcoder
Copy link
Member

@alexchandel I thought we had this discussion here already. However I don't see it on a quick scroll back, so 👍

@bcurran3
Copy link

bcurran3 commented Jul 27, 2019

Some reference that could possibly be implemented into the Chocolatey PS helper functions:

https://blogs.technet.microsoft.com/dsheehan/2018/10/27/powershell-taking-control-over-ctrl-c/
and
https://stackoverflow.com/questions/1710698/gracefully-stopping-in-powershell

I'd really love to see traction on this issue as I run into #1548 from time to time. My requested goal is that when an upgrade is aborted via ctrl-c, that Chocolatey would move the previous package files back from chocolatey\lib-bkp to chocolatey\lib so that the package isn't lost from package management.

I see the "0 - _Triaging" label on this issue, but I believe it should be considered a proper bug.

@omry
Copy link

omry commented Aug 24, 2019

This is something I can reliably reproduce with newly installed choco.

choco install miniconda3

see the prompt to install, remember I want -y:
ctrl+C
choco install -y

now I get that the package is already installed and I should use --force.

Running the same command again actually installs without a fuss.

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

8 participants