Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I resolve `The following packages have unmet dependencies`

Tags:

npm

ubuntu

I was using this script to install basic software, but had to interrupt because of slow internet speed. Now when I hit $ sudo apt-get install npm , I get following error

yask123@yaskslaptop:~$ sudo apt-get installed npm E: Invalid operation installed yask123@yaskslaptop:~$ sudo apt-get install npm 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:  npm : Depends: nodejs but it is not going to be installed        Depends: node-abbrev (>= 1.0.4) but it is not going to be installed        Depends: node-ansi (>= 0.3.0-2) but it is not going to be installed        Depends: node-ansi-color-table but it is not going to be installed        Depends: node-archy but it is not going to be installed        Depends: node-block-stream but it is not going to be installed        Depends: node-fstream (>= 0.1.22) but it is not going to be installed        Depends: node-fstream-ignore but it is not going to be installed        Depends: node-github-url-from-git but it is not going to be installed        Depends: node-glob (>= 3.1.21) but it is not going to be installed        Depends: node-graceful-fs (>= 2.0.0) but it is not going to be installed        Depends: node-inherits but it is not going to be installed        Depends: node-ini (>= 1.1.0) but it is not going to be installed        Depends: node-lockfile but it is not going to be installed        Depends: node-lru-cache (>= 2.3.0) but it is not going to be installed        Depends: node-minimatch (>= 0.2.11) but it is not going to be installed        Depends: node-mkdirp (>= 0.3.3) but it is not going to be installed        Depends: node-gyp (>= 0.10.9) but it is not going to be installed        Depends: node-nopt (>= 3.0.1) but it is not going to be installed        Depends: node-npmlog but it is not going to be installed        Depends: node-once but it is not going to be installed        Depends: node-osenv but it is not going to be installed        Depends: node-read but it is not going to be installed        Depends: node-read-package-json (>= 1.1.0) but it is not going to be installed        Depends: node-request (>= 2.25.0) but it is not going to be installed        Depends: node-retry but it is not going to be installed        Depends: node-rimraf (>= 2.2.2) but it is not going to be installed        Depends: node-semver (>= 2.1.0) but it is not going to be installed        Depends: node-sha but it is not going to be installed        Depends: node-slide but it is not going to be installed        Depends: node-tar (>= 0.1.18) but it is not going to be installed        Depends: node-underscore but it is not going to be installed        Depends: node-which but it is not going to be installed E: Unable to correct problems, you have held broken packages. 
like image 496
yask Avatar asked Oct 26 '14 08:10

yask


People also ask

How do I fix packages have unmet dependencies?

One of the most common causes of unmet dependencies are PPAs, especially when used to upgrade the existing package in Ubuntu repositories. To solve the problem you have three options: disable, purge (revert back to original package in Ubuntu repositories) or remove PPA.

How do I fix unmet dependencies and broken packages?

The command to have Ubuntu fix unmet dependencies and broken packages is sudo apt-get install -f from the man page: -f, --fix-broken Fix; attempt to correct a system with broken dependencies in place.

What is unmet dependencies error in Ubuntu?

Ubuntu uses centralized packaging system ,Ie Every package is depends to some other packages .When we installs a package it's dependencies will be installed ,The unmet dependencies error occurs when the the dependencies of the package is not available for installation

How do I fix unmet dependencies on apt-get?

Type in sudo aptitude install PACKAGENAME, where PACKAGENAME is the package you’re installing, and press Enter to execute it. This will try to install the package via aptitude instead of apt-get, which should potentially fix the unmet dependencies issue.

How do I Purge a failed package in apt-get?

Since apt-get works alongside with dpkg, which means apt-get will obey dpkg function. You call apt-get to purge the failed package you were trying to install in the system, and then you call build-dep command, which apt-get will grab and install dependencies individually belonging to this package, so that way they'll satisfy the package prior.


Video Answer


2 Answers

If sudo apt-get install -f <package-name> doesn't work, try aptitude:

sudo apt-get install aptitude sudo aptitude install <package-name> 

Aptitude will try to resolve the problem.

As an example, in my case, I still receive some error when try to install libcurl4-openssl-dev:

sudo apt-get install -f libcurl4-openssl-dev 

So i try aptitude, it turns out I have to downgrade some packages.

The following actions will resolve these dependencies:      Keep the following packages at their current version:     1)     libyaml-dev [Not Installed]                          Accept this solution? [Y/n/q/? (n)  The following actions will resolve these dependencies:      Downgrade the following packages:                                     1)     libyaml-0-2 [0.1.4-3ubuntu3.1 (now) -> 0.1.4-3ubuntu3 (trusty)]  Accept this solution? [Y/n/q/?] (Y) 
like image 89
Tapa Avatar answered Oct 11 '22 13:10

Tapa


First of all try this

sudo apt-get update sudo apt-get clean sudo apt-get autoremove 

If error still persists then do this

sudo apt --fix-broken install sudo apt-get update && sudo apt-get upgrade sudo dpkg --configure -a sudo apt-get install -f 

Afterwards try this again:

sudo apt-get install npm 

But if it still couldn't resolve issues check for the dependencies using sudo dpkg --configure -a and remove them one-by-one . Let's say dependencies are on npm then go for this ,

sudo apt-get remove nodejs sudo apt-get remove npm 

Then go to /etc/apt/sources.list.d and remove any node list if you have. Then do a

sudo apt-get update 

Then check for the dependencies problem again using sudo dpkg --configure -a and if it's all clear then you are done . Later on install npm again using this

v=8   # set to 4, 5, 6, ... as needed curl -sL https://deb.nodesource.com/setup_$v.x | sudo -E bash - 

Then install the Node.js package.

sudo apt-get install -y nodejs 

The answer above will work for general cases also(for dependencies on other packages like django ,etc) just after first two processes use the same process for the package you are facing dependency with.

like image 23
Akash Kandpal Avatar answered Oct 11 '22 13:10

Akash Kandpal