Cannot install vim

32,394

Solution 1

You have an outdated package list.

Run this command:

sudo apt-get update && sudo apt-get install vim

What that will do is update your package list, and then try to install vim.

Solution 2

When doing

$ sudo apt-get install vim

I got :

Reading package lists... Done  
Building dependency tree  
Reading state information... Done

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.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 vim : Depends: vim-common (= 2:7.3.154+hg~74503f6ee649-2ubuntu2) but 2:7.3.154+hg~74503f6ee649-2ubuntu3 is to be installed
E: Unable to correct problems, you have held broken packages.

To solve this problem, I did:

sudo apt-get remove vim-common 
sudo apt-get clean && sudo apt-get purge 
sudo apt-get update && sudo apt-get install vim

I must say that the previous fix did the trick for vim installation but not for others packages which still gave me the same kind of issue(E: Unable to correct problems, you have held broken packages)

After searching a little more, I found on another forum a better fix. The fix has been given by Liam Proven(http://ubuntu.5.n6.nabble.com/E-Unable-to-correct-problems-you-have-held-broken-packages-td4355181.html).

In Synaptic (if you have it installed) or System Settings | Software Sources. Look for the option to find the fastest server. It usually picks a lightly-loaded mirror near you.

After setting the fastest server, I do not have any problem. Hope that is useful.

Solution 3

I also had broken packages in Synaptic and nothing was able to be installed. For me this solved the issue:

sudo apt-get clean && sudo apt-get purge

And then try to reinstall

Solution 4

The clue to the answer is in the "Unable to correct problems, you have held broken packages."

For broken package state issues I turn to aptitude (sudo apt-get install aptitude) because it has handy shortcuts for queing arbitrary changes to package states: for instance "+" to unhold, "=" to hold, "-" to remove, "_" to purge, and "g" to apply queued changes. "/" to search for packages.

But these commands may work. Un-holding vim-common is the important bit:

sudo apt-get update
echo vim-common install | sudo dpkg --set-selections
sudo apt-get install vim

Solution 5

You can also download vim

cd Downloads
sudo apt-get download vim
Get:1 Downloading vim 2:7.3.154+hg~74503f6ee649-2ubuntu3 [1,038 kB]
Fetched 1,038 kB in 17s (59.7 kB/s)                                                          
root@onezero:/home/one/Downloads/vim# ls
vim_7.3.154+hg~74503f6ee649-2ubuntu3_amd64.deb

then

dpkg -i vim_7.3.154+hg~74503f6ee649-2ubuntu3_amd64.deb

I hope this will help you

you can also check HOWTO: Install downloaded .DEB packages (and their dependencies) in 2 steps

Share:
32,394

Related videos on Youtube

Max Popp
Author by

Max Popp

Updated on September 18, 2022

Comments

  • Max Popp
    Max Popp over 1 year

    I am running Ubuntu 11.10, as Xubuntu, in an AMD 64 pc, configured as dual boot with Windows 7.

    I tried installing vim with this:

    sudo apt-get install vim
    

    I got this error message:

    The following packages have unmet dependencies:
     vim : Depends: vim-common (= 2:7.3.154+hg~74503f6ee649-2ubuntu2) but 2:7.3.154+hg~74503f6ee649-2ubuntu3 is to be installed
    E: Unable to correct problems, you have held broken packages.
    

    I only have a very faint idea of what the problem is, and none whatsoever on how to correct this. Hope you guys can help.

  • john-jones
    john-jones over 11 years
    Changing which server Synaptic is downloading from fixed the bug for me. Thanks!