在 Ubuntu 14.04 上,当我尝试安装应用程序或者只是执行以下任务时:
sudo apt-get upgrade
我最后总会得到这样的信息:
Do you want to continue? [Y/n] Abort.
我没有输入任何内容,它只是自动中止。
你们能帮助我吗?
=======[ 编辑 #1 8 月 12 日 ]======== 我在这里复制了整个终端文本。我在这里运行了 2 个命令,即:sudo apt-get update,然后在得到结果后,我运行 sudo apt-get upgrade
以下是从终端复制的文本:
franzbiely@Franz-Gizmo:~$ sudo apt-get update
Ign http://archive.ubuntu.com trusty InRelease
Ign http://ppa.launchpad.net trusty InRelease
Ign http://archive.canonical.com trusty InRelease
Ign http://extras.ubuntu.com trusty InRelease
Ign http://archive.ubuntu.com trusty-updates InRelease
Ign http://ppa.launchpad.net trusty InRelease
Hit http://archive.canonical.com trusty Release.gpg
Hit http://extras.ubuntu.com trusty Release.gpg
Ign http://archive.ubuntu.com trusty-backports InRelease
Ign http://ppa.launchpad.net trusty InRelease
Hit http://archive.canonical.com trusty Release
Hit http://extras.ubuntu.com trusty Release
Hit http://archive.canonical.com trusty/partner Sources
Hit http://extras.ubuntu.com trusty/main Sources
Hit http://ppa.launchpad.net trusty Release.gpg
Ign http://dl.google.com stable InRelease
Hit http://ppa.launchpad.net trusty Release.gpg
Hit http://archive.canonical.com trusty/partner amd64 Packages
Hit http://dl.google.com stable Release.gpg
Hit http://ppa.launchpad.net trusty Release.gpg
Hit http://archive.canonical.com trusty/partner i386 Packages
Hit http://extras.ubuntu.com trusty/main amd64 Packages
Ign http://archive.ubuntu.com trusty-security InRelease
Hit http://dl.google.com stable Release
Hit http://ppa.launchpad.net trusty Release
Hit http://extras.ubuntu.com trusty/main i386 Packages
Hit http://dl.google.com stable/main amd64 Packages
Hit http://archive.ubuntu.com trusty Release.gpg
Hit http://ppa.launchpad.net trusty Release
Hit http://dl.google.com stable/main i386 Packages
Get:1 http://archive.ubuntu.com trusty-updates Release.gpg [933 B]
Hit http://ppa.launchpad.net trusty Release
Hit http://archive.ubuntu.com trusty-backports Release.gpg
Hit http://ppa.launchpad.net trusty/main amd64 Packages
Get:2 http://archive.ubuntu.com trusty-security Release.gpg [933 B]
Hit http://ppa.launchpad.net trusty/main i386 Packages
Hit http://archive.ubuntu.com trusty Release
Get:3 http://archive.ubuntu.com trusty-updates Release [59.7 kB]
Hit http://ppa.launchpad.net trusty/main amd64 Packages
Ign http://archive.canonical.com trusty/partner Translation-en_PH
Hit http://ppa.launchpad.net trusty/main i386 Packages
Ign http://archive.canonical.com trusty/partner Translation-en
Ign http://extras.ubuntu.com trusty/main Translation-en_PH
Ign http://extras.ubuntu.com trusty/main Translation-en
Ign http://dl.google.com stable/main Translation-en_PH
Ign http://dl.google.com stable/main Translation-en
Hit http://archive.ubuntu.com trusty-backports Release
Hit http://ppa.launchpad.net trusty/main amd64 Packages
Get:4 http://archive.ubuntu.com trusty-security Release [59.7 kB]
Hit http://ppa.launchpad.net trusty/main i386 Packages
Hit http://archive.ubuntu.com trusty/main amd64 Packages
Hit http://archive.ubuntu.com trusty/restricted amd64 Packages
Hit http://archive.ubuntu.com trusty/universe amd64 Packages
Hit http://archive.ubuntu.com trusty/multiverse amd64 Packages
Hit http://archive.ubuntu.com trusty/main i386 Packages
Hit http://archive.ubuntu.com trusty/restricted i386 Packages
Hit http://archive.ubuntu.com trusty/universe i386 Packages
Hit http://archive.ubuntu.com trusty/multiverse i386 Packages
Hit http://archive.ubuntu.com trusty/main Translation-en
Hit http://archive.ubuntu.com trusty/multiverse Translation-en
Hit http://archive.ubuntu.com trusty/restricted Translation-en
Hit http://archive.ubuntu.com trusty/universe Translation-en
Get:5 http://archive.ubuntu.com trusty-updates/main amd64 Packages [290 kB]
Ign http://ppa.launchpad.net trusty/main Translation-en_PH
Ign http://ppa.launchpad.net trusty/main Translation-en
Ign http://ppa.launchpad.net trusty/main Translation-en_PH
Ign http://ppa.launchpad.net trusty/main Translation-en
Ign http://ppa.launchpad.net trusty/main Translation-en_PH
Ign http://ppa.launchpad.net trusty/main Translation-en
Get:6 http://archive.ubuntu.com trusty-updates/restricted amd64 Packages [5,820 B]
Get:7 http://archive.ubuntu.com trusty-updates/universe amd64 Packages [177 kB]
Get:8 http://archive.ubuntu.com trusty-updates/multiverse amd64 Packages [7,381 B]
Get:9 http://archive.ubuntu.com trusty-updates/main i386 Packages [286 kB]
Get:10 http://archive.ubuntu.com trusty-updates/restricted i386 Packages [5,820 B]
Get:11 http://archive.ubuntu.com trusty-updates/universe i386 Packages [178 kB]
Get:12 http://archive.ubuntu.com trusty-updates/multiverse i386 Packages [7,598 B]
Hit http://archive.ubuntu.com trusty-updates/main Translation-en
Hit http://archive.ubuntu.com trusty-updates/multiverse Translation-en
Hit http://archive.ubuntu.com trusty-updates/restricted Translation-en
Get:13 http://archive.ubuntu.com trusty-updates/universe Translation-en [87.0 kB]
Hit http://archive.ubuntu.com trusty-backports/main amd64 Packages
Hit http://archive.ubuntu.com trusty-backports/restricted amd64 Packages
Hit http://archive.ubuntu.com trusty-backports/universe amd64 Packages
Hit http://archive.ubuntu.com trusty-backports/multiverse amd64 Packages
Hit http://archive.ubuntu.com trusty-backports/main i386 Packages
Hit http://archive.ubuntu.com trusty-backports/restricted i386 Packages
Hit http://archive.ubuntu.com trusty-backports/universe i386 Packages
Hit http://archive.ubuntu.com trusty-backports/multiverse i386 Packages
Hit http://archive.ubuntu.com trusty-backports/main Translation-en
Hit http://archive.ubuntu.com trusty-backports/multiverse Translation-en
Hit http://archive.ubuntu.com trusty-backports/restricted Translation-en
Hit http://archive.ubuntu.com trusty-backports/universe Translation-en
Get:14 http://archive.ubuntu.com trusty-security/main amd64 Packages [125 kB]
Get:15 http://archive.ubuntu.com trusty-security/restricted amd64 Packages [14 B]
Get:16 http://archive.ubuntu.com trusty-security/universe amd64 Packages [43.4 kB]
Get:17 http://archive.ubuntu.com trusty-security/multiverse amd64 Packages [1,147 B]
Get:18 http://archive.ubuntu.com trusty-security/main i386 Packages [122 kB]
Get:19 http://archive.ubuntu.com trusty-security/restricted i386 Packages [14 B]
Get:20 http://archive.ubuntu.com trusty-security/universe i386 Packages [43.3 kB]
Get:21 http://archive.ubuntu.com trusty-security/multiverse i386 Packages [1,402 B]
Hit http://archive.ubuntu.com trusty-security/main Translation-en
Hit http://archive.ubuntu.com trusty-security/multiverse Translation-en
Hit http://archive.ubuntu.com trusty-security/restricted Translation-en
Hit http://archive.ubuntu.com trusty-security/universe Translation-en
Ign http://archive.ubuntu.com trusty/main Translation-en_PH
Ign http://archive.ubuntu.com trusty/multiverse Translation-en_PH
Ign http://archive.ubuntu.com trusty/restricted Translation-en_PH
Ign http://archive.ubuntu.com trusty/universe Translation-en_PH
Fetched 1,502 kB in 3min 15s (7,672 B/s)
Reading package lists... Done
franzbiely@Franz-Gizmo:~$ sudo apt-get upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following packages have been kept back:
gnome-settings-daemon-schemas linux-headers-generic linux-signed-generic
linux-signed-image-generic unity-settings-daemon
The following packages will be upgraded:
linux-libc-dev
1 upgraded, 0 newly installed, 0 to remove and 5 not upgraded.
Need to get 784 kB of archives.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] Abort.
franzbiely@Franz-Gizmo:~$
=======[/ 结束编辑]==============
答案1
当 apt-get 需要交互式确认但无法从 stdin 读取输入时,它会中止。
例如,任何人(具有待升级)都可以通过将 /dev/null 重定向到 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:~$
这就引出了下一个问题,当你调用时,什么接管了 stdin sudo apt-get upgrade
?这是一个比较棘手的问题,可能涉及你的 sudo 配置或你用来调用命令的终端或 shell...
或者,如果您只是需要一个解决方法,您可以传递-y
以apt-get
跳过提示:sudo apt-get -y upgrade
答案2
我的问题是我试图通过将多个命令复制粘贴到控制台来同时运行它们
apt-get update
apt-get upgrade
apt-get dist-upgrade
apt-get install build-essential
...
分别调用每个命令解决了我的问题
答案3
我刚刚在 18.04.2 上遇到了这个问题。 update
,,update
并且dist-upgrade
运行正常;install
,中止失败。 是的,使用-y
工作。
但是,我发现我的文件存在问题/etc/apt/sources.list
,通过将其恢复为发行版附带的默认值(您可以很容易地在线找到您的版本),就可以完全解决问题。
我怀疑添加其自己的存储库的备用第三方库脚本之一犯了一个错误。
我建议制作一个备份,尝试替换文件,确保所有权和权限与原始文件相同,然后执行sudo apt update
,然后尝试安装。
从此以后我就没再遇到任何问题。
答案4
尝试运行以下命令,如果有帮助,请在评论中告诉我您在运行之前做了什么apt-get
:
perl -MFcntl -e 'fcntl STDIN, F_SETFL, fcntl(STDIN, F_GETFL, 0) & ~O_NONBLOCK'
解释:(apt-get
和许多其他程序)要求 STDIN 处于阻塞模式。一些流氓程序将其设置为非阻塞模式。好奇心促使我请您找出、记录并提交这些流氓程序的错误。其他解决方法:运行bash
并键入exit
以返回当前 bash。Bash 将在进入时正确设置。
仅供参考,运行以下命令可能会引发该问题:
perl -MFcntl -e 'fcntl STDIN, F_SETFL, fcntl(STDIN, F_GETFL, 0) | O_NONBLOCK'