10

When I was trying to install Git on Ubuntu 16.04, I get an error. The command I used to install git is:

sudo apt-get install git

The error I encountered was:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
  git : Depends: liberror-perl but it is not going to be installed
        Depends: git-man (> 1:2.7.4) but it is not going to be installed
        Depends: git-man (< 1:2.7.4-.) but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or
specify a solution).

Even though I used the suggested command (apt-get -f install) to install git the error still persists. Anyone who has the idea to fix this problem?

6
  • 2
    yes, I ran it but the problem still persists – Chamber Feb 24 '17 at 6:18
  • 1
    Please try sudo apt-get update && sudo apt-get dist-upgrade && apt-get -f install – George Udosen Feb 24 '17 at 6:19
  • 1
    Already tried, same error encountered – Chamber Feb 24 '17 at 6:25
  • 1
    Lets see if gdebi will help: sudo apt-get install gdebi && sudo gdebi git – George Udosen Feb 24 '17 at 6:46
  • 1
    The previous solution (sudo apt-get update && sudo apt-get dist-upgrade && apt-get -f install) worked, I just had the 3 commands ran one by one. Thanks for the help – Chamber Feb 24 '17 at 6:52
17

Some times our systems may not be up-to-date to receive an install so we can update with:

  • update package information:

    sudo apt-get update
    
  • upgrade packages on system and fix broken packages in the process:

    sudo apt-get -f dist-upgrade
    
  • only fix broken packages:

    sudo apt-get -f install
    
2

I had the same problem with liberror-perl when trying to install git. The other answers (sudo apt-get update && sudo apt-get dist-upgrade && apt-get -f install) didn't work for me.

From manually following the chain of dependency problems by trying to install each package directly, it looks like the problem is with perl-base:

$ sudo apt install liberror-perl
  liberror-perl : Depends: perl but it is not going to be installed

$ sudo apt install perl
  perl : Depends: perl-base (= 5.22.1-9) but 5.22.1-9ubuntu0.5 is to be installed

$ sudo apt install perl-base
  perl-base is already the newest version (5.22.1-9ubuntu0.5).

So the perl package depends on an outdated version of perl-base. I'm not sure how that was caused, but I suspect at one point a newer version was available, perhaps from a temporary apt source that was later removed on my system. I fixed the problem by downgrading perl-base to the version perl wants:

$ sudo apt install -f perl-base=5.22.1-9

After that, git installs properly. Just in case there was a newer perl-base version available, I tried upgrading it, but the above version was also the latest version:

$ sudo apt install perl-base=\*
perl-base is already the newest version (5.22.1-9).
Selected version '5.22.1-9' (Ubuntu:16.04/xenial [amd64]) for 'perl-base'

As far as I know this should not cause any problems, but YMMV.

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