为什么像我按下“ N”键一样,apt-get本身会中止?


29

在Ubuntu 14.04上,当我尝试安装应用程序或什至只是这样做时:

sudo apt-get upgrade

我总是在最后收到以下消息:

Do you want to continue? [Y/n] Abort.

我没有输入任何内容,它只是自动中止。

你们能帮我吗?

======= [编辑#1 Aug 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:~$ 

======= [/结束编辑] =============


如果输入会y怎样?
2014年

@Eliah是的,请在询问[Y / n]时实际尝试给它y。我通常建议他们这样做,sudo apt-get update | pastebinit并给我们链接,因为它可能会输出很长的时间……
Tim

输入y后,它只是说找不到命令,因为我在〜$中输入y
Francis M Albores 2014年

是的,@ tim,问题在于即使我没有输入任何内容,我也已经中止了,所以我进入了($命令行)。
弗朗西斯·阿尔伯斯

@EliahKagan当我回到家里的电脑时,我将尝试复制所有内容并将其粘贴到此处。
弗朗西斯·阿尔伯斯

Answers:


28

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配置或用于调用命令的终端或外壳程序。

或者,如果你只需要一个解决方法,您可以传递-yapt-get跳过提示:sudo apt-get -y upgrade


1
同样的问题,我宁愿知道在吃什么。这发生在八岳。其他终端(例如KDE的Konsole或mlterm)仍能正常运行。
哈米德

1
我也遇到了这个问题(在Debian上,我知道这是Ask Ubuntu,但也许仍然会有所帮助...),也不知道为什么会发生,但是我在终端仿真器应用程序中打开了一个新标签,问题消失了。
杰克逊

这就像一种罪过,是其中的大罪。据称更新后它消失了。
哈米德

我看到了,这可以解释为什么在使用之后发生了这种情况wildmidi,这显然是在播放midi时试图捕获一些输入以改变音量等,但是在segfault之类的东西之后没有正确释放。
hsandt

6

我的问题是我试图通过将它们复制粘贴到控制台来一次运行多个命令

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

分别调用每个命令解决了我的问题


2
两个软件包名称之间也可能存在“隐藏”回车符。当我卸下此运输工具时,使用单行命令安装了该运输工具,例如sudo apt-get install libssl-dev libdb-dev libdb++-dev
–undersound

@undersound谢谢!您应该将此添加为答案。安装单个软件包时遇到了这个问题,但是我已经从网页中复制了它,并随同回车。apt-get仍然给了我提示,但是(我认为)是接受了我的意见,\rY而不是Y因此而中止了
anotherdave

1

我在18.04.2。上遇到了这个问题。 updateupdatedist-upgrade工作得很好; install,失败并中止。 是的,使用-y有效。

但是,我发现文件中存在问题/etc/apt/sources.list,并且通过将其恢复为发行版随附的默认设置(您可以轻松地在网上找到您的版本)完全解决了该问题。

我怀疑添加自己的存储库的备用第三方库脚本之一出错了。

我建议你做一个备份,请尝试更换文件,确保所有权和权限是一样的原稿,然后做一个sudo apt update,然后尝试你的安装。

从那以后我没有任何问题。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.