Why does apt-get abort by itself, as though I'd pressed 'N'?

apt-get aborts when it wants interactive confirmation but can't read input from stdin.

For example, anyone (with pending upgrades) can reproduce this behavior by redirecting /dev/null to stdin:

skath@tahiti:~$ sudo apt-get upgrade < /dev/null
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following packages will be upgraded:
  libcgmanager0
1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 29.3 kB of archives.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] Abort.
skath@tahiti:~$

This leads to the next question, what's taking over stdin when you're calling sudo apt-get upgrade? That's a trickier question and might involve your sudo configuration or the terminal or shell you're using to invoke the command...

Or, if you just need a workaround, you can pass -y to apt-get to skip the prompt: sudo apt-get -y upgrade


my problem was that I tried to run several commands at once by copy-pasting them into console

apt-get update
apt-get upgrade
apt-get dist-upgrade
apt-get install build-essential
...

Calling each command separately solved my problem


I just had this problem on 18.04.2. update, update, and dist-upgrade worked fine; install, failed with an abort. Yes, using -y worked.

However, I found that there was a problem in my /etc/apt/sources.list file, and that by restoring it to the default that came with the distribution (you can find your version online easily enough), that completely solved the problem.

I suspect that one of the alternate third party library scripts that was adding its own repository made a mistake.

I'd recommend making a backup copy, try replacing the file, ensuring the ownership and permissions are the same as the original, and then doing a sudo apt update, then try your install.

I haven't had any problems since.