15

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?

pomsky
  • 68,507
nass
  • 1,440
  • 2
  • 20
  • 33
  • 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 09:44
  • could be... but now is the time to install 14.04 :) – nass Apr 17 '14 at 09: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 09: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
  • @terdon caret: http://askubuntu.com/questions/211912/whats-the-caret-mean-in-apt-get – Rinzwind Apr 17 '14 at 10:33
  • @nass the - means remove package (that way you can install 10 packages and remove 1 in between that could be a conflicting package) – Rinzwind Apr 17 '14 at 10:35
  • @Rinzwind well I'll be... Where in the world is that documented? – terdon Apr 17 '14 at 10:37
  • try apt-cache dumpavail | grep ^Task @terdon (it will show all the special cases). – Rinzwind Apr 17 '14 at 10:38
  • @Rinzwind ah! It's Ubuntu specific, that returns nothing on my Debian but oodles of stuff on an Ubuntu. Not documented in either man or info pages though. Grrr. – terdon Apr 17 '14 at 10:42
  • This can be a very good question for a competitive examination on linux ;) and will have a horrible number of people answering incorrectly! Not to aggravate your loss; a good discovery I would say :D – jobin Apr 17 '14 at 11:12

2 Answers2

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.

terdon
  • 100,812
  • 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
  • @terdon Yes, but this one is totally unexpected. – Kartik Apr 17 '14 at 12:07
  • This is specially cool if you need to install, remove and upgrade several packages at once and you are lazy to do it manually. Or in case you need to change a dependency. – Braiam Apr 17 '14 at 12:49
  • 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
  • documented or not, this seems like a bomb waiting to go off. conflicting packages can be usually removed automatically, and if not, it does not look like a HUGE deal to have to remove them in a separate command apt-get remove. I honestly find that this is a huge risk for marginal flexibility that it offers. and not because I happened to fall in the trap this time. – nass Apr 17 '14 at 15:04
  • @musiKk. i disagree musikk. a hyphen is a character that is often used as part of package names. what is more , you can easily miss seeing it in a large group of installs. on the other hand apt-get install is easy to spot in an install command of Any length. even at the [Y/N] stage you still could miss the remove packages , or at least trust apt if it tells you that it will remove some package. Hardly anyone's mind will consider rechecking the command. – nass Apr 17 '14 at 21:48
  • I can see how this could be useful but it is also pretty dangerous. I think this functionality should be qualified - i.e. you need to add a command line stitch to run in this mode. Then you can do your magic if you want, but the ordinary user doesn't accidentally kill their system. – Adam Apr 18 '14 at 00:12
  • 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 00:48
6

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

Jos
  • 29,224