Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I tried to install Scala with the typesafe stack and got into trouble. Now I cannot do much with apt (except update), the broken package seems to be impossible to remove/clean:

Here's the result of apt-get -f install:

$ 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:
  gstreamer0.10-fluendo-mp3:i386 scala-library liboil0.3:i386
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
  scala
The following NEW packages will be installed:
  scala
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
4 not fully installed or removed.
Need to get 21.5 MB of archives.
After this operation, 0 B of additional disk space will be used.
Do you want to continue [Y/n]? Y
Get:1 http://apt.typesafe.com/ unicorn/main scala all 2.9.2-400 [21.5 MB]
Fetched 21.5 MB in 13s (1,567 kB/s)                                                                          
(Reading database ... 329381 files and directories currently installed.)
Unpacking scala (from .../scala_2.9.2-400_all.deb) ...
dpkg: error processing /var/cache/apt/archives/scala_2.9.2-400_all.deb (--unpack):
 trying to overwrite '/usr/share/java/scala-partest.jar', which is also in package scala-library 2.9.1.dfsg-3
dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
Errors were encountered while processing:
 /var/cache/apt/archives/scala_2.9.2-400_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

Here's my attempt to autoremove:

$ apt-get autoremove
E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
phdp@desktop:~/work/manuscripts/ideas/ibm_food_webs$ sudo apt-get autoremove
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:
 typesafe-stack : Depends: scala but it is not installed
E: Unmet dependencies. Try using -f.
share|improve this question
add comment

8 Answers 8

I fixed my issue using this command:

sudo dpkg -i --force-overwrite path-to-the-deb-file
  • If --force-overwrite doesn't work, try:

    sudo dpkg -i --force-overwrite-all path-to-the-deb-file

In your case:

sudo dpkg -i --force-overwrite /var/cache/apt/archives/scala_2.9.2-400_all.deb
share|improve this answer
add comment

It seems like removing the scala-library package and then reconfiguring might work. So you're on the right track. The correct commands are, in this order:

sudo apt-get autoremove
sudo apt-get install -f

Your autoremove command did not succeed because you did not run it as root (using sudo).

share|improve this answer
add comment

The following worked for me (although I'm on x86):

$ sudo vim /var/lib/apt/lists/apt.typesafe.com_dists_unicorn_main_binary-i386_Packages

Change the line reading

Filename: pool/main/s/scala/scala_     2.9.2-400_all.deb

to:

Filename: pool/main/s/scala/scala_%20%20%20%20%202.9.2-400_all.deb

Followed by:

sudo apt-get remove scala-library
sudo apt-get remove scala
sudo apt-get install scala
share|improve this answer
    
Nano is easier for some users. Perhaps you can document that one can also use sudo nano or gksudo gedit? –  hexafraction Sep 26 '12 at 15:25
add comment

The easy way to open synaptic. It will states you that a broken packages are found so you have to locate the broken packages and just remove then you can do whatever you like.

share|improve this answer
add comment

In my case I couldn't update the system because of the following error when trying 'sudo apt-get install -f':

update-alternatives: error: /var/lib/dpkg/alternatives/package_name broken: invalid status

A remedy was to remove the file from /var/lib/dpkg/alternatives and repeat above command. I ran it a few times until all invalid packages were fixed. In my case it prevented me from configuring java properly.

share|improve this answer
add comment

i had this problem once, for some reaspon i think it was a skype package

actually i recall i had it twice, once when the skype package only was broken in this case if its only a few 1.open software updater, and wait for it to load 2. click settings 3. click other software tab These are all your packages, look at your console output, use the last few lines to locate which package it is and remove it, or do it one by one until you no longer get the error

If it was like i had once, all packages were unable to be reieved correctly same as above, but click the Ubuntu Software tab

check only the first and third box Select main server from the dropdown, click close sudo apt-get update

share|improve this answer
add comment

In my case this worked:

sudo dpkg -P package_name 

(not deb name)

share|improve this answer
add comment
  1. I used sudo apt-get install -f or sudo apt-get -f install

    I used this to locate the broken package. In my case it was something with jack audio.

  2. Root nautlius with sudo nautlius and delete the former located package

share|improve this answer
    
Please revise your answer with respect to "Root nuatilus with sudo nautilus". –  user25656 Feb 7 '13 at 1:43
    
The question says that sudo apt-get install -fdidn't work... –  papukaija Jul 1 '13 at 23:53
add comment

protected by Community Jul 9 at 11:33

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

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