3

So my problem is quite easy to describe: I can't install anything in my Ubuntu installation. apt-get stopped working after I tried to fix some other package errors I was getting. Now I'm nowhere.

Let me try to explain how I ended up in this situation...

I was trying to install maven2. I did sudo apt-get install maven2 and it didn't work. It told me that git-core is missing a new line in the end. So what I did was look up this error and try to fix it. I ended up finding a Python script which would add new lines to files in /var/lib/dpkg/info. This is when everything got worse... Nothing would work anymore and the errors are even more!

This is that Python script:

import os

dpkg_path = '/var/lib/dpkg/info/'
paths = os.listdir(dpkg_path)
for path in paths:
    path = dpkg_path + path
    f = open(path, 'a+')
    data = f.read()
    if len(data) > 1 and data[-1:] != '\n':
        f.write('\n')
        print 'added newline character to:', path
    f.close()  

Now when I try to install maven via sudo apt-get install maven (I blamed maven2 for these errors, so I tried with maven only), I got the following error:

Fetched 49.5 MB in 2min 7s (387 kB/s): error processing package dpkg (--configure): ⠀package dpkg is not ready for configuration cannot configure (current status `half-installed') Errors were encountered while processing: ⠀dpkg E: Sub-process /usr/bin/dpkg returned an error code (1)

There are some other apt-get commands which I can't currently recall that outputted even more longer errors. I'll update this question if I encounter them again.

What do I do to fix this?


Edit

I did what I was asked in the comments section (trying to install maven and then run sudo apt-get install -f and this is the whole output in the terminal:

bash: /etc/bash_completion.d/git: No such file or directory
dugi@Dugi:~$ sudo apt-get install maven
[sudo] password for dugi: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libantlr-java libcommons-validator-java libdoxia-sitetools-java
  libjdependency-java libmaven-archiver-java libmaven-clean-plugin-java
  libmaven-compiler-plugin-java libmaven-dependency-tree-java
  libmaven-filtering-java libmaven-install-plugin-java
  libmaven-jar-plugin-java libmaven-plugin-tools-java
  libmaven-reporting-impl-java libmaven-resources-plugin-java
  libmaven-shade-plugin-java libplexus-compiler-java libplexus-digest-java
  libplexus-velocity-java libwerken.xpath-java velocity
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
  libaether-java libaopalliance-java libasync-http-client-java libcdi-api-java
  libcglib-java libgeronimo-interceptor-3.0-spec-java libguice-java
  libjackrabbit-java libjcommander-java libmaven-parent-java libnetty-java
  libplexus-classworlds2-java libplexus-cli-java libplexus-containers1.5-java
  libplexus-utils2-java libsisu-guice-java libsisu-ioc-java libwagon2-java
  libyaml-snake-java testng
Suggested packages:
  libaopalliance-java-doc libasync-http-client-java-doc libjcommander-java-doc
  libplexus-classworlds2-java-doc libplexus-cli-java-doc
  libplexus-utils2-java-doc
The following NEW packages will be installed:
  libaether-java libaopalliance-java libasync-http-client-java libcdi-api-java
  libcglib-java libgeronimo-interceptor-3.0-spec-java libguice-java
  libjackrabbit-java libjcommander-java libmaven-parent-java libnetty-java
  libplexus-classworlds2-java libplexus-cli-java libplexus-containers1.5-java
  libplexus-utils2-java libsisu-guice-java libsisu-ioc-java libwagon2-java
  libyaml-snake-java maven testng
0 upgraded, 21 newly installed, 0 to remove and 129 not upgraded.
78 not fully installed or removed.
Need to get 0 B/49.5 MB of archives.
After this operation, 12.4 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
dpkg: error processing package dpkg (--configure):
 package dpkg is not ready for configuration
 cannot configure (current status `half-installed')
Errors were encountered while processing:
 dpkg
E: Sub-process /usr/bin/dpkg returned an error code (1)
dugi@Dugi:~$ sudo apt-get install -f
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  fop java-wrappers libantlr-java libatinject-jsr330-api-java libbatik-java
  libclassworlds-java libcommons-configuration-java libcommons-io-java
  libcommons-jexl2-java libcommons-jxpath-java libcommons-net2-java
  libcommons-validator-java libcommons-vfs-java libdom4j-java libdoxia-java
  libdoxia-sitetools-java libfop-java libganymed-ssh2-java libguava-java
  libhttpclient-java libhttpcore-java libitext1-java libjaxen-java
  libjdependency-java libjdom1-java libjetty-java libjsoup-java libjsr305-java
  libmaven-archiver-java libmaven-clean-plugin-java
  libmaven-compiler-plugin-java libmaven-dependency-tree-java
  libmaven-filtering-java libmaven-install-plugin-java
  libmaven-jar-plugin-java libmaven-plugin-tools-java
  libmaven-reporting-impl-java libmaven-resources-plugin-java
  libmaven-scm-java libmaven-shade-plugin-java libmaven2-core-java
  libmodello-java libnetbeans-cvsclient-java libplexus-ant-factory-java
  libplexus-archiver-java libplexus-bsh-factory-java libplexus-build-api-java
  libplexus-cipher-java libplexus-classworlds-java libplexus-compiler-java
  libplexus-container-default-java libplexus-containers-java
  libplexus-digest-java libplexus-i18n-java libplexus-interactivity-api-java
  libplexus-interpolation-java libplexus-io-java libplexus-sec-dispatcher-java
  libplexus-utils-java libplexus-velocity-java libqdox-java libslf4j-java
  libwagon-java libwerken.xpath-java libxbean-java libxmlgraphics-commons-java
  libxpp2-java libxpp3-java velocity
Use 'apt-get autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 129 not upgraded.
78 not fully installed or removed.
Need to get 0 B/41.3 MB of archives.
After this operation, 0 B of additional disk space will be used.
dpkg: error processing package dpkg (--configure):
 package dpkg is not ready for configuration
 cannot configure (current status `half-installed')
dpkg: error processing package libbsh-java (--configure):
 package libbsh-java is not ready for configuration
 cannot configure (current status `half-installed')
dpkg: error processing package bsh (--configure):
 package bsh is not ready for configuration
 cannot configure (current status `half-installed')
dpkg: error processing package libjaxp1.3-java (--configure):
 package libjaxp1.3-java is not ready for configuration
 cannot configure (current status `half-installed')
dpkg: error processing package libxalan2-java (--configure):
No apport report written because MaxReports is reached already
                                                              No apport report written because MaxReports is reached already
                                            No apport report written because MaxReports is reached already
                           package libxalan2-java is not ready for configuration
 cannot configure (current status `half-installed')
dpkg: error processing package libbsf-java (--configure):
 package libbsf-java is not ready for configuration
 cannot configure (current status `half-installed')
dpkg: error processing package libavalon-framework-java (--configure):
 package libavalon-framework-java is not ready for configuration
 cannot configure (current status `half-installed')
dpkg: error processing package libcommons-io-java (--configure):
 package libcommons-io-java is not ready for configuration
 cannot configure (current status `half-installed')
dpkg: error processing package java-wrappers (--configure):
 package java-wrappers is not ready for configuration
 cannot configure (current status `half-installed')
dpkg: error processing package libbatik-java (--configure):
 package libbatik-java is not ready for configuration
 cannot configure (current status `half-installed')
dpkg: error processing package libxmlgraphNo apport report written because MaxReports is reached already
                        No apport report written because MaxReports is reached already
      No apport report written because MaxReports is reached already
                                                                    No apport report written because MaxReports is reached already
                                                  No apport report written because MaxReports is reached already
                                No apport report written because MaxReports is reached already
              No apport report written because MaxReports is reached already
                                                                            ics-commons-java (--configure):
 package libxmlgraphics-commons-java is not ready for configuration
 cannot configure (current status `half-installed')
dpkg: error processing package libfop-java (--configure):
 package libfop-java is not ready for configuration
 cannot configure (current status `half-installed')
dpkg: error processing package fop (--configure):
 package fop is not ready for configuration
 cannot configure (current status `half-installed')
dpkg: error processing package libantlr-java (--configure):
 package libantlr-java is not ready for configuration
 cannot configure (current status `half-installed')
dpkg: error processing package libatinject-jsr330-api-java (--configure):
 package libatinject-jsr330-api-java is not ready for configuration
 cannot configure (current status `half-installed')
dpkg: error processing package libclassworlds-java (--configure):
 package libclassworlds-java is not ready for configuration
 cannot configure (current status `half-installed')
dpkg: erNo apport report written because MaxReports is reached already
                                                                      No apport report written because MaxReports is reached already
                                                    No apport report written because MaxReports is reached already
                                  No apport report written because MaxReports is reached already
                No apport report written because MaxReports is reached already
                                                                              No apport report written because MaxReports is reached already
                                                            ror processing package libcommons-configuration-java (--configure):
 package libcommons-configuration-java is not ready for configuration
 cannot configure (current status `half-installed')
dpkg: error processing package libcommons-jexl2-java (--configure):
 package libcommons-jexl2-java is not ready for configuration
 cannot configure (current status `half-installed')
dpkg: error processing package libcommons-jxpath-java (--configure):
 package libcommons-jxpath-java is not ready for configuration
 cannot configure (current status `half-installed')
dpkg: error processing package libcommons-net2-java (--configure):
 package libcommons-net2-java is not ready for configuration
 cannot configure (current status `half-installed')
dpkg: error processing package libcommons-validator-java (--configure):
 package libcommons-validator-java is not ready for configuration
 cannot configure (current status `half-installed')
dpkg: error processing package libcommons-vfs-java (--configure):
 package libcommNo apport report written because MaxReports is reached already
                                                                              No apport report written because MaxReports is reached already
                                                            No apport report written because MaxReports is reached already
                                          No apport report written because MaxReports is reached already
                        No apport report written because MaxReports is reached already
      No apport report written because MaxReports is reached already
                                                                    No apport report written because MaxReports is reached already
                                                  ons-vfs-java is not ready for configuration
 cannot configure (current status `half-installed')
dpkg: error processing package libjaxen-java (--configure):
 package libjaxen-java is not ready for configuration
 cannot configure (current status `half-installed')
dpkg: error processing package libxpp2-java (--configure):
 package libxpp2-java is not ready for configuration
 cannot configure (current status `half-installed')
dpkg: error processing package libxpp3-java (--configure):
 package libxpp3-java is not ready for configuration
 cannot configure (current status `half-installed')
dpkg: error processing package libdom4j-java (--configure):
 package libdom4j-java is not ready for configuration
 cannot configure (current status `half-installed')
dpkg: error processing package libhttpcore-java (--configure):
 package libhttpcore-java is not ready for configuration
 cannot configure (current status `half-installed')
dpkg: error processing package libhttpclient-java (--configure):
 package libhNo apport report written because MaxReports is reached already
                                                                           No apport report written because MaxReports is reached already
                                                         No apport report written because MaxReports is reached already
                                       No apport report written because MaxReports is reached already
                     No apport report written because MaxReports is reached already
   No apport report written because MaxReports is reached already
                                                                 ttpclient-java is not ready for configuration
 cannot configure (current status `half-installed')
dpkg: error processing package libitext1-java (--configure):
 package libitext1-java is not ready for configuration
 cannot configure (current status `half-installed')
dpkg: error processing package liblog4j1.2-java (--configure):
 package liblog4j1.2-java is not ready for configuration
 cannot configure (current status `half-installed')
dpkg: error processing package libplexus-interpolation-java (--configure):
 package libplexus-interpolation-java is not ready for configuration
 cannot configure (current status `half-installed')
dpkg: error processing package libplexus-utils-java (--configure):
 package libplexus-utils-java is not ready for configuration
 cannot configure (current status `half-installed')
dpkg: error processing package libplexus-container-default-java (--configure):
 package libplexus-container-default-java is not ready for configuration
 cannot configure (current status `half-inNo apport report written because MaxReports is reached already
                        No apport report written because MaxReports is reached already
      No apport report written because MaxReports is reached already
                                                                    No apport report written because MaxReports is reached already
                                                  No apport report written because MaxReports is reached already
                                No apport report written because MaxReports is reached already
              stalled')
dpkg: error processing package libjsr305-java (--configure):
 package libjsr305-java is not ready for configuration
 cannot configure (current status `half-installed')
dpkg: error processing package libguava-java (--configure):
 package libguava-java is not ready for configuration
 cannot configure (current status `half-installed')
dpkg: error processing package libplexus-classworlds-java (--configure):
 package libplexus-classworlds-java is not ready for configuration
 cannot configure (current status `half-installed')
dpkg: error processing package libxbean-java (--configure):
 package libxbean-java is not ready for configuration
 cannot configure (current status `half-installed')
dpkg: error processing package libplexus-containers-java (--configure):
 package libplexus-containers-java is not ready for configuration
 cannot configure (current status `half-installed')
dpkg: error processing package libplexus-i18n-java (--configure):
 package libplexus-i18n-java is not ready for conNo apport report written because MaxReports is reached already
                               No apport report written because MaxReports is reached already
             No apport report written because MaxReports is reached already
                                                                           No apport report written because MaxReports is reached already
                                                         No apport report written because MaxReports is reached already
                                       No apport report written because MaxReports is reached already
                     No apport report written because MaxReports is reached already
   figuration
 cannot configure (current status `half-installed')
dpkg: error processing package libdoxia-java (--configure):
 package libdoxia-java is not ready for configuration
 cannot configure (current status `half-installed')
dpkg: error processing package libexcalibur-logkit-java (--configure):
 package libexcalibur-logkit-java is not ready for configuration
 cannot configure (current status `half-installed')
dpkg: error processing package libjdom1-java (--configure):
 package libjdom1-java is not ready for configuration
 cannot configure (current status `half-installed')
dpkg: error processing package libwerken.xpath-java (--configure):
 package libwerken.xpath-java is not ready for configuration
 cannot configure (current status `half-installed')
dpkg: error processing package velocity (--configure):
 package velocity is not ready for configuration
 cannot configure (current status `half-installed')
dpkg: error processing package libplexus-velocity-java (--configure):
 package libplexuNo apport report written because MaxReports is reached already
                                                                               No apport report written because MaxReports is reached already
                                                             No apport report written because MaxReports is reached already
                                           No apport report written because MaxReports is reached already
                         No apport report written because MaxReports is reached already
       No apport report written because MaxReports is reached already
                                                                     s-velocity-java is not ready for configuration
 cannot configure (current status `half-installed')
dpkg: error processing package libdoxia-sitetools-java (--configure):
 package libdoxia-sitetools-java is not ready for configuration
 cannot configure (current status `half-installed')
dpkg: error processing package libganymed-ssh2-java (--configure):
 package libganymed-ssh2-java is not ready for configuration
 cannot configure (current status `half-installed')
dpkg: error processing package libjdependency-java (--configure):
 package libjdependency-java is not ready for configuration
 cannot configure (current status `half-installed')
dpkg: error processing package libslf4j-java (--configure):
 package libslf4j-java is not ready for configuration
 cannot configure (current status `half-installed')
dpkg: error processing package libjetty-java (--configure):
 package libjetty-java is not ready for configuration
 cannot configure (current status `half-installed')
dpkg: error processing package libjsoup-java (--configure):
 package libjsoup-java is not ready for configuration
 cannot configure (current status `half-installed')
dpkg: too many errors, stopping
Errors were encountered while processing:
 dpkg
 libbsh-java
 bsh
 libjaxp1.3-java
 libxalan2-java
 libbsf-java
 libavalon-framework-java
 libcommons-io-java
 java-wrappers
 libbatik-java
 libxmlgraphics-commons-java
 libfop-java
 fop
 libantlr-java
 libatinject-jsr330-api-java
 libclassworlds-java
 libcommons-configuration-java
 libcommons-jexl2-java
 libcommons-jxpath-java
 libcommons-net2-java
 libcommons-validator-java
 libcommons-vfs-java
 libjaxen-java
 libxpp2-java
 libxpp3-java
 libdom4j-java
 libhttpcore-java
 libhttpclient-java
 libitext1-java
 liblog4j1.2-java
 libplexus-interpolation-java
 libplexus-utils-java
 libplexus-container-default-java
 libjsr305-java
 libguava-java
 libplexus-classworlds-java
 libxbean-java
 libplexus-containers-java
 libplexus-i18n-java
 libdoxia-java
 libexcalibur-logkit-java
 libjdom1-java
 libwerken.xpath-java
 velocity
 libplexus-velocity-java
 libdoxia-sitetools-java
 libganymed-ssh2-java
 libjdependency-java
 libslf4j-java
 libjetty-java
 libjsoup-java
Processing was halted because there were too many errors.
E: Sub-process /usr/bin/dpkg returned an error code (1)
dugi@Dugi:~$ 
5
  • Try sudo apt-get install maven and then when it fails try sudo apt-get install -f and post the results of that, if possible. EDIT: please post from usr@host:$ sudo apt-get install .... so we can see the whole output
    – Mitch
    Jun 12, 2014 at 17:44
  • Okay, did that and posted the result up in the question. Thank you :)
    – aborted
    Jun 12, 2014 at 18:46
  • can you post the results of sudo dpkg --configure -a and then sudo apt-get install -f again?
    – Mitch
    Jun 12, 2014 at 18:50
  • Oh boy, my guess is you probably broke most of your packages. You already have a long list of programs to repair, and you are probably going to need to force an installation on several of them. Once you fix this initial set, you are probably going to have a similar problem with most if not all of your packages. You can write a script to un-do your changes and try again, or you can re-install. Re-install is going to be faster and in the long run more reliable. Your data in /home will be preserved (do not format the partition).
    – Panther
    Jun 12, 2014 at 19:13
  • @musher When I try to run sudo dpkg --configure -a I get the following message: dugi@Dugi:~/Desktop$ sudo dpkg --configure -a dpkg: error: corrupt info database format file '/var/lib/dpkg/info/format'.
    – aborted
    Jun 14, 2014 at 10:23

1 Answer 1

1

Here is a script to undo changes:

     #!/bin/sh
     files="/var/lib/dpkg/info/*"
     mkdir /tmp/backup
     for i in $files
     do
        cp $i /tmp/backup                # save file in case of errors
        sed '$d' $i > $i.out             # remove last line and put result in .out
        mv  $i.out $i                    # rename file as original
     done

Save script in file and exec:

     sudo sh file

In order to verify the result, try

     diff -r /var/lib/dpkg/info /tmp/backup

If and only if diff shows only blank line, retry:

     sudo dpkg --configure -a

else restore file from /tmp/backup

3
  • How do I restore the files from /tmp/backup/ to /var/lib/dpkg/info? I don't have permissions to do any changes in the lib folder.
    – aborted
    Jun 14, 2014 at 10:21
  • 1
    sudo cp /tmp/backup/* /var/lib/dpkg/info/*
    – Lety
    Jun 14, 2014 at 15:10
  • if script doesn't work, can you post diff -r /var/dpkg/info /tmp/backup output?
    – Lety
    Jun 14, 2014 at 15:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .