Ubuntu – Apt-get can not install or remove any package

apt

When I try to install ia32-libs in apt gui, it tell me:

  
ruby-vmc: Depends: ruby-rubyzip2 (>= 2.0.1) but 2.0.1-0ubuntu4 have installed  
          Depends: libhighline-ruby1.9.1 but %s not installed  
          Depends: ruby-rest-client (>= 1.6.1) but 1.6.7-1 have installed  
          Depends: ruby-terminal-table (>= 1.4.2) but 1.4.2-0ubuntu3 have installed  
          Depends: ruby-json-pure (>= 1.5.1) but %s not installed  

Next is the error when I execute: sudo apt-get -f install

installArchives() failed: 
| Collecting changes [0] - Stage 1/5


Committing to: /etc/
modified vmware/vmnet8/dhcpd/dhcpd.leases

| Running pre_commit hooks - Stage 3/5


Committed revision 159.
(Reading database ... 
(Reading database ... 5%
(Reading database ... 10%
(Reading database ... 15%
(Reading database ... 20%
(Reading database ... 25%
(Reading database ... 30%
(Reading database ... 35%
(Reading database ... 40%
(Reading database ... 45%
(Reading database ... 50%
(Reading database ... 55%
(Reading database ... 60%
(Reading database ... 65%
(Reading database ... 70%
(Reading database ... 75%
(Reading database ... 80%
(Reading database ... 85%
(Reading database ... 90%
(Reading database ... 95%
(Reading database ... 100%
(Reading database ... 491611 files and directories currently installed.)
Unpacking ruby-json-pure (from .../ruby-json-pure_1.5.1-0ubuntu3_all.deb) ...
dpkg: error processing /var/cache/apt/archives/ruby-json-pure_1.5.1-0ubuntu3_all.deb (--unpack):
 trying to overwrite '/usr/lib/ruby/vendor_ruby/json.rb', which is also in package ruby-json 1.6.3-1
No apport report written because MaxReports is reached already
Errors were encountered while processing:
 /var/cache/apt/archives/ruby-json-pure_1.5.1-0ubuntu3_all.deb
dpkg: dependency problems prevent configuration of ruby-vmc:
 ruby-vmc depends on ruby-json-pure (>= 1.5.1); however:
  Package ruby-json-pure is not installed.
dpkg: error processing ruby-vmc (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of cloudfoundry-client:
 cloudfoundry-client depends on ruby-vmc (= 0.3.10-0ubuntu10); however:
  Package ruby-vmc is not configured yet.
dpkg: error processing cloudfoundry-client (--configure):
 dependency problems - leaving unconfigured

When I execute:

sudo apt-get remove ruby-json-pure ruby-json
正在读取软件包列表... 完成
正在分析软件包的依赖关系树       
正在读取状态信息... 完成       
**package ruby-json-pure not installed,so it will not be removed**
You maybe use “apt-get -f install” to correct this error:
unsatisfied dependices:
 libjson-ruby : depends on: ruby-json but it will not be installed
 libjson-ruby1.8 : depends on: ruby-json but it will not be installed
 ruby-vmc : depends on: ruby-json-pure (>= 1.5.1) but it will not be installed
E: unsatisfied dependices。Please try to execute “apt-get -f install”。

So now I can not remove or install anything . Please help to solve this problem step by step, thanks.

Best Answer

It looks like you have conflicting repositories configured and packages from those repositories are both trying to install and are conflicting. This is not an simple answer fix. Usually its a step by step of finding which packages conflict, removing them and installing the packages you want. If you are not very familiar with this process, it may be best to ask in a chat channel.

The first step, which I can answer is given in the output you pasted.

dpkg: error processing /var/cache/apt/archives/ruby-json-pure_1.5.1-0ubuntu3_all.deb (--unpack):
  trying to overwrite '/usr/lib/ruby/vendor_ruby/json.rb', which is also in package ruby-json 1.6.3-1

So the ruby-json package is conflicting with the ruby-json-pure package. Whoever made the packages didn't correctly specify the conflicts-with on the package. We should file a bug.

You could start by trying to remove both packages and installing one

$ sudo apt-get remove ruby-json-pure ruby-json

I just tried to unsuccessfully recreate the error on my 12.10 system and I do not have a ruby-json-pure pacakge available. What repositories do you have enabled?

Finally, I'll suggest that instead of using system ruby, you consider using rbenv so that you can have both ruby-json and ruby-json-pure in different environments.

Related Question