7

I just walked into the trap of calling

sudo apt-get install autoremove

I did it because I was unable to install sudo apt-get install libopencv-dev because of unmet dependencies. Now my ros-indigo installation is broke, opencv is still not installed and I also cannot reinstall it.

When trying to install it I get only

E: Unable to correct problems, you have held broken packages.

I fear that I'm really close to killing my entire package-dependency system. Can someone help me please?

Can I somehow use the file /var/log/apt to reverse the step of deleting ros?

  • Have you tried running sudo apt-get install -f? – user364819 Feb 25 '16 at 15:05
  • Also this is giving me an error: Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. – mcExchange Feb 25 '16 at 15:09
9

I don't Know if there is any simpler way but if you look at /var/log/apt/history.log you can see what was removed. Just reinstall each package that was removed.

Using this may save your time

echo '#!/bin/bash' > restore
echo sudo apt-get install `grep Remove /var/log/apt/history.log | tail -1 | sed -e 's|Remove: ||g' -e 's|([^)]*)||g' -e 's|:[^ ]* ||g' -e 's|,||g'` >> restore
chmod +x restore 
./restore
  • this is a giant list of the form Commandline: apt-get autoremove Remove: ros-indigo-tf:amd64 (1.11.7-0trusty-20160111-112853-0800), ros-indigo-xacro:amd64 (1.9.5-0trusty-20160110-105433-0800), ... and so on (ca 1000 entries). Rewriting everything in the form sudo apt-get install ros-indigo-tf:amd64 ros-indigo-xacro:amd64 ... can become very tedious. Isn't there an automatic command to install them ? – mcExchange Feb 25 '16 at 14:57
  • Also the error E: Unable to correct problems, you have held broken packages. troubles me. Can I find out where it exactly comes from (which package) ? – mcExchange Feb 25 '16 at 15:00
  • answer was edited – storm Feb 25 '16 at 15:02
  • Thanks, but there is still something broke :(. Package libswresample0 is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source E: Package 'libswresample0' has no installation candidate – mcExchange Feb 25 '16 at 15:07
  • Commenting here so I don't lose this. +1 Can't tell you how many times I have ran autoremove and it removed something I needed to keep. This was very simple to run and worked flawless. Thank you! – Terrance Jul 6 '17 at 23:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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