15

This question already has an answer here:

In an attempt to install cuda, I copy-pasted some apt-get install packages. For unknown reasons the line that I got run in the end is the following:

sudo apt-get install libgtk2.0-

The result was that many packages got removed. Randomly picking a few:

libreoffice-*
python-*
xfce4-* 

The list is huge. A considerable number of system parts have been uninstalled. Now this seems like a serious deviation from what I expect when I run apt-get install.

What is going on?

marked as duplicate by pomsky, karel, Zanna command-line Apr 8 at 6:10

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 2
    13.04 is end of life so this is a good moment to install 13.10 ;-) There are special characters at the end of a package that invoke special actions (I know the ^ at the end invokes 'tasksel (sudo apt-get install lamp-server^)). The - I did not find yet (hard to search for :P ) but that could be something special too. – Rinzwind Apr 17 '14 at 9:44
  • could be... but now is the time to install 14.04 :) – nass Apr 17 '14 at 9:52
  • 1
    @Rinzwind all fun aside, - is a often used character, if it means anything remotely close to 'remove package' it should be handled with care. Let alone that when I say 'install' I SURELY don't mean 'uninstall' ... – nass Apr 17 '14 at 9:57
  • @Rinzwind AFAIK, the ^ just anchors the regex to the beginning of the string. Where do you get the taskel info? It's not mentioned in the man page. Good call on the - though, it is indeed a special character at the end of a package name. – terdon Apr 17 '14 at 10:32
21

The problem is the following (from man apt-get):

install

install is followed by one or more packages desired for installation or upgrading. Each package is a package name, not a fully qualified filename (for instance, in a Debian system, apt-utils would be the argument provided, not apt-utils_0.9.12.1_amd64.deb). All packages required by the package(s) specified for installation will also be retrieved and installed. The /etc/apt/sources.list file is used to locate the desired packages. If a hyphen is appended to the package name (with no intervening space), the identified package will be removed if it is installed. Similarly a plus sign can be used to designate a package to install. These latter features may be used to override decisions made by apt-get's conflict resolution system.

So, adding a hyphen to the end of a package name means "remove that package". Specifically, in your case, it would remove these:

Note, selecting 'libgtk2.0-doc' for regex 'libgtk2.0'
Note, selecting 'libgtk2.0-cil' for regex 'libgtk2.0'
Note, selecting 'libgtk2.0-bin' for regex 'libgtk2.0'
Note, selecting 'libgtk2.0-common' for regex 'libgtk2.0'
Note, selecting 'libgtk2.0-0' for regex 'libgtk2.0'
Note, selecting 'libgtk2.0-cil-dev' for regex 'libgtk2.0'
Note, selecting 'libgtk2.0-0-dbg' for regex 'libgtk2.0'
Note, selecting 'libgtk2.0-dev' for regex 'libgtk2.0'

In other words, you removed the entire gtk2 library set, and a lot of programs depend on gtk2. As a result, a lot of programs were removed.

So, no, this is not a bug. It is, admittedly, surprising behavior if you don't know about it but it is documented and intended.

  • 1
    good find @terdon sometimes man trumps google :D – Rinzwind Apr 17 '14 at 10:36
  • 1
    This is not only suprising but also dangerous. One single character can destroy your computer! IMO, This should be removed and a seperate command should be made for it. – Kartik Apr 17 '14 at 11:54
  • @Kartik many single characters can destroy your computer. Consider, for example, rm -f /usr and rm -rf /usr :) – terdon Apr 17 '14 at 11:56
  • 1
    @Kartik: Disagree. Yes, it is surprising but there is a prompt and if you blindly hit "y" when asked a question by the package management tool, that's a disaster waiting to happen. ALWAYS read this stuff or use a GUI tool. – musiKk Apr 17 '14 at 13:56
  • 3
    People, you're barking up the wrong tree here. I didn't write the thing, I just read the man page. Please file your bugs with the apt devs. :P – terdon Apr 18 '14 at 0:48
6

Take a look in /var/log/apt/history.log to see what exactly has been removed. Then, just reinstall these packages.

  • 2
    Not exactly an answer, its a remedy! – jobin Apr 17 '14 at 11:08
  • @Jobin Fair point. – Jos Apr 17 '14 at 11:34
  • oh yes, this is quite a save :) – nass Apr 17 '14 at 15:05
  • great, the names of the packages are interleaved with a whole bunch of package versions.. it will be impossible to just re run the whole list effortlessly :( – nass Apr 17 '14 at 21:47
  • 1
    @nass It should be possible to write a script that strips off everything between parentheses etc. But that would be a whole new question. – Jos Apr 17 '14 at 22:54

Not the answer you're looking for? Browse other questions tagged or ask your own question.