Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

For example:

$ sudo apt-get install curl
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:
bsh : Depends: libjline-java but it is not going to be installed
groovy : Depends: libjline-java but it is not going to be installed
rhino : Depends: libjline-java but it is not going to be installed
E: Unmet dependencies. 

Try 'apt-get -f install' with no packages (or specify a solution).

I get the same or similar errors when I attempt to install clojure1.3, leiningen, and several other packages.

When I try the suggestion made in the error message, this is what happens:

$ sudo apt-get -f install 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
  diffstat linux-headers-3.2.0-26-generic linux-headers-3.2.0-26 dh-apparmor dkms html2text libmail-sendmail-perl libsys-hostname-long-perl
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
  libjline-java
Suggested packages:
  libjline-java-doc
The following NEW packages will be installed:
  libjline-java
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
23 not fully installed or removed.
Need to get 0 B/72.0 kB of archives.
After this operation, 129 kB of additional disk space will be used.
Do you want to continue [Y/n]? Y
(Reading database ... 226243 files and directories currently installed.)
Unpacking libjline-java (from .../libjline-java_1.0-1_all.deb) ...
dpkg: error processing /var/cache/apt/archives/libjline-java_1.0-1_all.deb (--unpack):
 trying to overwrite '/usr/share/java/jline.jar', which is also in package scala 2.9.2-400
Errors were encountered while processing:
 /var/cache/apt/archives/libjline-java_1.0-1_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

$ sudo apt-get upgrade
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:
 bsh : Depends: libjline-java but it is not installed
 groovy : Depends: libjline-java but it is not installed
 rhino : Depends: libjline-java but it is not installed
E: Unmet dependencies. Try using -f.

Please help me resolve this issue. Thanks.

share|improve this question
    
Did you install a ppa for the programs ? If so you must run sudo apt-get update first to activate the ppa you installed. – Mark Kirby Aug 15 '12 at 12:45
    
Also looks live you need to install java, search for it in software center – Mark Kirby Aug 15 '12 at 12:46
    
Probably a duplicate of this Q&A or at least the solution should help – danjjl Aug 15 '12 at 12:51
    
@markkirby, what's a ppa? Sorry, novice here. – missingfaktor Aug 15 '12 at 16:58
    
@markkirby, I have run sudo apt-get update if that is what you are asking. – missingfaktor Aug 15 '12 at 16:59
up vote 47 down vote accepted

To fix your problem run

sudo dpkg -i --force-overwrite /var/cache/apt/archives/libjline-java_1.0-1_all.deb

check everything is fixed by running : sudo apt-get -f install

If you still have problems rerun the first step with any dpkg: error processing (...) remaining

Solution found on webupd8

share|improve this answer
3  
That worked. Thanks a lot! – missingfaktor Aug 15 '12 at 17:05
    
Thanks for the solution , its worked for me too. – Raja Feb 15 '13 at 16:34
2  
This will effectively install the package but the problem remains when both package tries to use the same library/file/binary. – Braiam May 11 '14 at 23:11
    
Legend answer bro – Stevie G Mar 26 at 7:30

Please don't go for the above answer directly, if you face this kind of trying to overwrite error.Because dpkg --force option may broke your system.

So first remove the package scala(conflicting package),

sudo dpkg -P scala

And then try to fix the dependencies by running,

sudo apt-get install -f

Also see this answer for more detailed explanation about this error.

share|improve this answer
    
Not so sure about this advice. I think it depends on the situation. In the link to your earlier posting, there is a conflict from two versions of the same software. I agree there that one should remove the older software first. However, if there is a problem with how two different programs were packaged and the file that is being overwritten is identical or otherwise harmless, then I don't see a problem with the advice. No, not ideal...but it's probably a bit extreme to ask someone to not go for the a particular answer if the alternative is to wait until the problem is bug fixed... – Ray Dec 2 '15 at 13:11

@danjjl's command works for .deb files. I found this command works with aptitude:

sudo apt-get -o Dpkg::Options::="--force-overwrite" install <package-name>
share|improve this answer
    
Thank you!! Would never have figured this out. – mpen Dec 14 '15 at 4:34

Just for completenes' sake, here's the option not-for-the-faint-of-heart (or if your really know what you are doing):

dpkg -i --force-all whatever.deb

;)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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