web-dev-qa-db-fra.com

Impossible d'installer un paquet via apt-get

Donc mon problème est assez facile à décrire: je ne peux rien installer dans mon installation Ubuntu. apt-get A cessé de fonctionner après avoir essayé de corriger d'autres erreurs de package que j'obtenais. Maintenant je ne suis nulle part.

Permettez-moi d'essayer d'expliquer comment je me suis retrouvé dans cette situation ...

J'essayais d'installer maven2. J'ai fait Sudo apt-get install maven2 Et cela n'a pas fonctionné. Il m'a dit que git-core Manquait une nouvelle ligne à la fin. J'ai donc recherché cette erreur et essayé de la corriger. J'ai fini par trouver un script Python qui ajouterait de nouvelles lignes aux fichiers dans /var/lib/dpkg/info. C'est à ce moment que tout a empiré ... Rien ne fonctionnerait plus et les erreurs sont encore plus !

C'est que Python:

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()  

Maintenant, lorsque j'essaie d'installer maven via Sudo apt-get install maven (J'ai blâmé maven2 Pour ces erreurs, j'ai donc essayé avec maven uniquement), j'ai eu l'erreur suivante :

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)

Il y a d'autres commandes apt-get Dont je ne me souviens pas actuellement qui ont généré des erreurs encore plus longues. Je mettrai à jour cette question si je les rencontre à nouveau.

Que dois-je faire pour résoudre ce problème?


Éditer

J'ai fait ce qu'on m'a demandé dans la section des commentaires (en essayant d'installer maven puis d'exécuter Sudo apt-get install -f Et c'est la sortie entière dans le 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:~$ 
2
Aborted

Voici un script pour annuler les modifications:

     #!/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

Enregistrez le script dans le fichier et exécutez:

     Sudo sh file

Afin de vérifier le résultat, essayez

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

Si et seulement si diff n'affiche qu'une ligne vierge, réessayez:

     Sudo dpkg --configure -a

sinon restaurer le fichier à partir de/tmp/backup

1
Lety