Ubuntu error while installing package

Debugging Central

Debugging Central

This page is part of the debugging series — pages with debugging details for a variety of Ubuntu packages.

Contents

  1. Introduction
  2. Known issues

    1. Corrupted package archive

      1. Not a Debian format archive
      2. Corrupted filesystem tarfile
      3. —fsys-tarfile
      4. short read — Input/output error
      5. Exec format error
      6. triggers ci file contains unknown directive syntax
      7. lzma : decoder error
      8. files list file missing final newline / contains empty filename
    2. Inconsistent state

      1. Package in bad inconsistent state
      2. package is already installed and configured
    3. Other issues

      1. Can’t access archive
      2. No space left on device
      3. DbDriver «config» is locked
      4. /var/lib/defoma/locked exists
      5. /etc/defoma/hints/FONTNAME.hints: Unable to open, or empty
  3. Non-bugs

    1. Segmentation Fault — Exit status 139
  4. Other resources
  5. TODO

Introduction

This page lists some general issues that users might encounter while performing updates of their system. Apport will usually detect these failures and file a bug in Launchpad. These bugs can be identified by the bug tag ‘apport-package’ and can occur on nearly any package.

There are usually log file attached to the report which differs depending on the kind of install/upgrade:

  • Package install/upgrade: DpkgTerminalLog

  • Distribution upgrade: VarLogDistupgradeMain and VarLogDistupgradeApttermlog

Detailed informations about debugging updatemanager can be found at DebuggingUpdateManager.

Documented below are the most commonly reported issues. For each case there is a description and a sample report and when applicable there is a workaround or fix and the master report it should be marked a duplicate of.

Known issues

Corrupted package archive

These errors indicates a corrupted archive (.deb or files on disk) The root cause of the corruption may be a bad network connection, faulty hardware, hardware shutdown,…

For those report the common workaround and stock response is:

Thank you for taking the time to report this bug and helping to make Ubuntu better. It seems that there was an error caused by a corrupted archive. Please execute the following commands, as it will clear your package cache, in a terminal ( Applications -> Accessories -> Terminal ) :

sudo apt-get clean
sudo apt-get update

Then try performing the update again. This will likely resolve your issue. If so please set the bug’s status to Invalid. Thanks in advance!

Not a Debian format archive

  • Bug : provide a master report

This error indicated that the header of the .deb archive is not recognized as a valid debian format.

dpkg-deb: `/var/cache/apt/archives/libswscale0_4%3a0.5+svn20090706-2ubuntu2_i386.deb' is not a debian format archive 
dpkg: error processing /var/cache/apt/archives/libswscale0_4%3a0.5+svn20090706-2ubuntu2_i386.deb (--unpack): 
 subprocess dpkg-deb --control returned error exit status 2

Corrupted filesystem tarfile

  • Bug 320743

Unpacking libaccess-bridge-java (from .../libaccess-bridge-java_1.24.0-0ubuntu2_all.deb) ...
dpkg: error processing /var/cache/apt/archives/libaccess-bridge-java_1.24.0-0ubuntu2_all.deb (--unpack):
 corrupted filesystem tarfile - corrupted package archive
dpkg-deb: subprocess paste killed by signal (Broken pipe)

—fsys-tarfile

  • Bug : provide a master report
Unpacking replacement audacity-data ...
dpkg-deb: subprocess paste killed by signal (Broken pipe)
dpkg: error processing /var/cache/apt/archives/audacity-data_1.3.7-2ubuntu1_all.deb (--unpack):
 subprocess dpkg-deb --fsys-tarfile returned error exit status 2
Processing triggers for man-db ...
Errors were encountered while processing:
 /var/cache/apt/archives/audacity-data_1.3.7-2ubuntu1_all.deb

short read — Input/output error

  • Bug : provide a master report

The ‘short read’ error happens when trying to install a partially downloaded package. The front-end verify the integrity of the archive, but it is not the case if dpkg is invoked directly.

An input/output error is likely to mean filesystem corruption, hardware problems or no space left on hard disk. The typical errors are:

Unpacking linux-image-2.6.27-11-generic (from .../linux-image-2.6.27-11-generic_2.6.27-11.24_i386.deb) ...
Done.
dpkg-deb: subprocess paste killed by signal (Broken pipe)
dpkg: error processing /var/cache/apt/archives/linux-image-2.6.27-11-generic_2.6.27-11.24_i386.deb (--unpack):
 short read in buffer_copy (backend dpkg-deb during `./lib/modules/2.6.27-11-generic/kernel/drivers/infiniband/core/ib_uverbs.ko')

or

Unpacking replacement libfreetype6 ...
dpkg-deb (subprocess): error in buffer_read(stream): failed to write to pipe in copy: Input/output error
dpkg-deb: subprocess paste returned error exit status 2
dpkg: error processing /var/cache/apt/archives/libfreetype6_2.3.9-4ubuntu0.1_i386.deb (--unpack):
 short read in buffer_copy (backend dpkg-deb during `./usr/lib/libfreetype.so.6.3.20')

The suggestion is to run a manual fsck and look whether the hard drive or storage device is operating correctly (dmesg may contain helpful information too)

TODO: Write a standard response

Exec format error

  • Bug : 512096

This error indicates that the installation or removal script is corrupted. It is caused by a sudden system failure during dpkg operation (power failure, hardware failure, …) on filesystems supporting delayed allocation (like ext4, xfs, btrfs, …)

Empty files or files filed with garbage are left on the hard drive. The file causing the dpkg error is one of /var/lib/dpkg/info/PACKAGE_NAME.p*

This error can occur either during installation or removal of the package.

During installation of a package

Setting up flashplugin-installer (10.0.32.18ubuntu1) ...
dpkg (subprocess): unable to execute installed post-installation script: Exec format error
dpkg: error processing flashplugin-installer (--configure):
 subprocess installed post-installation script returned error exit status 2

During removal of a package

Removing gnome-do ...
dpkg (subprocess): unable to execute installed pre-removal script: Exec format error
dpkg: error processing gnome-do (--purge):
 subprocess installed pre-removal script returned error exit status 2

Workaround A: Finish the install

sudo apt-get clean
sudo aptitude download python-libvirt
sudo dpkg —unpack ./python-libvirt*.deb
sudo dpkg —configure python-libvirt

Workaround B: Remove the package and reinstall

sudo rm /var/lib/dpkg/info/flashplugin-installer.{postinst,prerm,postrm}
sudo apt-get remove —purge flashplugin-installer
sudo apt-get clean
sudo apt-get update

Then reinstall the package

Note: Change the package by the one which failed (check the log file)

Note about localized error message:
Finding this error in the log is not always easy because the error string has been localized.

  • Erreur de format pour exec()
  • Error de formato ejecutable
  • Errore di formato di exec
  • Exec format error
  • Formatfel på körbar fil
  • Érvénytelen végrehajtható fájlformátum
  • Exec formátum hiba
  • Verkeerd uitvoerbaar bestand
  • Exec 格式错误

triggers ci file contains unknown directive syntax

  • Bug 500042

This is the same kind of issue than the one above. It means that the trigger file is empty or corrupted. The file is /var/lib/dpkg/info/PACKAGE.triggers This error can occur during installation or removal of a package.

During installation of a package

Setting up ureadahead (0.90.3-2) ...
dpkg: error processing ureadahead (--configure):
 triggers ci file contains unknown directive syntax

Workaround

remove the file /var/lib/dpkg/info/PACKAGE.triggers
sudo rm /var/lib/dpkg/info/PACKAGE.triggers
and run
sudo dpkg —purge ureadahead
then clean your cache
sudo apt-get clean
and try performing the install of ureadahead again.

lzma : decoder error

  • Bug : provide a master report
Unpacking openjdk-6-jre-lib (from .../openjdk-6-jre-lib_6b12-0ubuntu6_all.deb) ...
lzma: Decoder error
dpkg-deb: subprocess <decompress> returned error exit status 1
dpkg: error processing /var/cache/apt/archives/openjdk-6-jre-lib_6b12-0ubuntu6_all.deb (--unpack):
 short read in buffer_copy (backend dpkg-deb during `./usr/lib/jvm/java-6-openjdk/jre/lib/ext/localedata.jar')

files list file missing final newline / contains empty filename

  • Bug 108189

This error indicates that the file /var/lib/dpkg/info/PACKAGE_NAME.list is corrupted ( empty or full of garbage ) The reason may be a disk error, a memory error, a process being interrupted during unpack, …

Typically these errors take the form :
files list file for package packagename contains empty filename
or
files list file for package packagename is missing final newline

Selecting previously deselected package linux-source-2.6.27.
(Reading database ... dpkg: error processing /var/cache/apt/archives/linux-source-2.6.27_2.6.27-9.19_all.deb (--unpack):
 files list file for package `libpoppler-glib3' is missing final newline

Workaround: Recreate the file list from .deb
This can be fixed, with a little work. If you have the .deb file for the offending package currently available on your system, then check its integrity by running:
dpkg —contents /var/cache/apt/archive/libgnome2-0_2.24.1-0ubuntu3_i386.deb
or get a .deb file by running :
sudo apt-get install —reinstall —download-only libgnome2-0

Once you have a valid .deb file, then you can reconstitute the file. First become root by using sudo -s (enter your administrative user password if necessary), and then use the following command (copy/paste and change the package name accordingly):

dpkg -c /var/cache/apt/archive/libgnome2-0_2.24.1-0ubuntu3_i386.deb | awk 
‘{if ($6 == «./») { print «/.»; } 
else if (substr($6, length($6), 1) == «/») 
{print substr($6, 2, length($6) — 2); } 
else { print substr($6, 2, length($6) — 1);}}’ 
> /var/lib/dpkg/info/libgnome2-0.list

Inconsistent state

Package in bad inconsistent state

  • Bug : provide a master report
Removing flashplugin-nonfree ...
dpkg: error processing flashplugin-installer (--purge):
 Package is in a very bad inconsistent state - you should
 reinstall it before attempting a removal.

Workaround A:

Please open a Terminal from the menu Applications->Accessories->Terminal and type or copy and paste the row below:

sudo apt-get —reinstall install cupsys
sudo dpkg —configure -a
sudo apt-get -f install

give your user password when requested, you don’t see nothing when you type it, then press enter.

Workaround B:

Try the command below to purge the offending packages :

sudo dpkg —purge —force-remove-reinstreq flashplugin-installer flashplugin-nonfree

Then to reinstall :

sudo apt-get install flashplugin-installer

package is already installed and configured

  • Bug : 541595

Conditions of this failure are unknown. Please provide any additional informations in the master report.

Note to triagers: Before marking a report as duplicate, be sure that there is no other error in the log file term.log . In other words, don’t blindly duplicate because the title says ‘already installed and configured’.

dpkg: error processing language-pack-ar (--configure):
 package language-pack-ar is already installed and configured

Workaround A:

Workaround B:

sudo apt-get install —reinstall language-pack-ar

Other issues

Can’t access archive

  • Bug : 523395

The source of this error is not clearly identified and needs further investigation (see comment #3 of the master report)

dpkg: error processing /media/cdrom0//pool/main/g/gcc-4.4/libstdc++6-4.4-dev_4.4.1-4ubuntu8_i386.deb (--unpack):
 cannot access archive: No such file or directory
dpkg: error processing /media/cdrom0//pool/main/g/gcc-4.4/g++-4.4_4.4.1-4ubuntu8_i386.deb (--unpack):
 cannot access archive: No such file or directory

No space left on device

  • Bug 105113 was a request to detect this prior to performing any updates.

  • Bug 312491 was a request to report to the user when running out of disk space.

This error is self-explanatory.

Unpacking replacement perl-base ...
dpkg: error processing /var/cache/apt/archives/perl-base_5.10.0-11.1ubuntu2.2_i386.deb (--unpack):
 failed in buffer_write(fd) (10, ret=-1): backend dpkg-deb during `./usr/lib/perl/5.10.0/IO.pm': No space left on device

Note about localized error message:
Despite the fact that there is no ambiguity regarding the cause of the failure, finding this error in the log is not always easy because the error string has been localized. Checking for the strings —unpack and buffer_write in the error log is a good indication too.

DbDriver «config» is locked

  • Bug 349469

  • Bug 377211

debconf: DbDriver "config": /var/cache/debconf/config.dat is locked by another process: Resource temporarily unavailable

fuser -v will return the locking process if any. Kill it and try performing the upgrade again. Most often, this is only a transient situation and fuser will return nothing. Simply performing the update again should solve this issue.

/var/lib/defoma/locked exists

  • Bug 386763

Under certain circumstances font packages failed to install with the following error:

Setting up ttf-dejavu-extra (2.28-1) ...
E: /var/lib/defoma/locked exists.
E: Another defoma process seems running, or you aren't root.
E: If you are root and defoma process isn't running undoubtedly,
E: it is possible that defoma might have aborted.
E: Please run defoma-reconfigure -f to fix its broken status.
dpkg: error processing ttf-dejavu-extra (--configure):
 subprocess post-installation script returned error exit status 1

Workaround

Open a terminal (Applications -> Accessories -> Terminal ) and run the following command:

$ sudo defoma-reconfigure -f

/etc/defoma/hints/FONTNAME.hints: Unable to open, or empty

  • Bug 521431

Under certain circumstances font packages failed to install with the following error:

Setting up ttf-konatu (24-3) ...
/etc/defoma/hints/ttf-konatu.hints: Unable to open, or empty.
dpkg: error processing ttf-konatu (--configure):
 subprocess installed post-installation script returned error exit status 1

This is due to a corrupted hint file.

Workaround

To workaround it, open a terminal and run the following commands:

$ sudo rm /var/lib/dpkg/info/FONTNAME.prerm
$ sudo apt-get remove --purge FONTNAME
$ sudo apt-get clean

Then try performing the install again. Replace the font file name (FONTNAME) by the font name failing on your system (e.g ttf-dejavu-extra, ttf-konatu, …)

Non-bugs

Common issues arising from hardware failures, common invalid bugs for this category.

Segmentation Fault — Exit status 139

  • Bug 493572

  • Bug 478841

If the installation failed with no reason with an exit status 139, that the configuration script is trivial and there is no other report of this kind for that package, then this is very likely a memory corruption error.

The error from the term.log will show something like this:

Setting up python-dateutil (1.4.1-2) ...
Segmentation fault
dpkg: error processing python-dateutil (--configure):
 subprocess post-installation script returned error exit status 139

There is not much we can do except the advice below:

Thanks for your report.

This looks like a hardware issue. Could you run memtest on your system? (boot a live CD / USB key and select test memory)

The reporter will most of the time says that the test reports error. If so, then close the report.

Note : an exit status 139 can also appear on other scenarios that aren’t related to faulty memory modules. For example, if you install a Hardy guest on a Lenny host using Xen, and then try an apt-get upgrade on the Hardy guest, that will fail with a segfault and an exit status 139 if you forget to disable /lib/tls as advised in the Xen Faq

Other resources

  • Kernel specific errors

  • Debugging Update manager

TODO

  • Add note about localized messages in log file and method to process those reports
  • Search for master reports, complete missing references in wiki and cross-reference report/wiki content
  • Add section ‘How to triage’ and merge the one from DebuggingUpdateManager

  • Add missing descriptions & workaround

  • Add section with common install/upgrade issues for specific packages ? only provide list of report + description ?

CategoryBugSquad CategoryDebugging

Introduction

Linux packages are compressed archives containing programs and files necessary to run them. The package distribution system is designed to be robust and simplify the application installation process.

However, a bad internet connection or misconfigured third-party installers can corrupt packages and cause problems on your system.

This article will show you how to troubleshoot and fix broken packages on Ubuntu using the available APT and DPKG tools.

How to fix broken packages in Ubuntu

Prerequisites

  • An account with sudo privileges
  • An Ubuntu system

Check for Updates

Start troubleshooting by rebuilding the list of dependencies. The --fix-missing option tells APT to ignore missing packages. The option ensures the update process is performed without APT returning an error.

sudo apt update --fix-missing
The --fix-missing option tells APT to ignore the missing packages

Force APT to Correct Missing Dependencies or Broken Packages

Missing package dependencies are a common reason for package-related errors.

1. Use apt install with the -f flag to tell APT to locate the missing packages and install them.

sudo apt install -f

APT lists the missing packages on your system.

The apt install tells APT to locate the missing packages and install them

2. Press ENTER to start the installation.

Note: If troubleshooting has led to Ubuntu needing to be reinstalled, please refer to our reinstallation guide How to Reinstall Ubuntu.

Force Reconfigure or Remove Broken Packages with DPKG

Broken packages may cause package manager configuration problems.

1. Reconfigure DPKG, the base package management system, with the following command:

sudo dpkg --configure -a

2. Check if DPKG marked some packages as needing a reinstall.

sudo dpkg -l | grep ^..R

3. If the command above returns a list of one or more packages, try removing the packages by typing:

sudo dpkg --purge --force-all [package-name]

The example below shows how to remove the corrupted vlc-plugin-base package.

Remove the corrupted vlc-plugin-base package

Warning: The dpkg --purge --force-all command removes a package even if the removal causes further dependency issues. Use the command with care.

4. After you finish troubleshooting, run the following command to clean up the system:

sudo apt clean

5. Then update the repositories again:

sudo apt update

Resolve DPKG Lock Issue

The DPKG lock error appears when trying to install a package while another process is using DPKG.

The DPKG lock error appears when trying to install a package while another process is using DPKG

However, sometimes the error occurs even if no other processes are using the package management system.

1. To fix the problem, remove the lock file manually:

sudo rm /var/lib/apt/lists/lock

2. Also, remove the lock in cache:

sudo rm /var/cache/apt/archives/lock

Deleting the lock enables you to use APT and DPKG again.

Conclusion

The article provided common ways of resolving problems caused by broken packages on Ubuntu.

For more information related to package management on Ubuntu, read:

  • How to List Installed Packages on Ubuntu
  • A Comprehensive Guide to Using Snap Packages on Ubuntu
  • How to Install Deb Files (Packages) on Ubuntu

I was trying to install a package using APT and I got error:

UserName@PCname:~$ sudo apt-get install php7.2

Reading package lists... Done
Building dependency tree       
Reading state information... Done
php7.2 is already the newest version (7.2.7-1+0~20180622080852.23+jessie~1.gbpfd8e2e).
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
4 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up php7.1-fpm (7.1.18-1+0~20180611145758.18+jessie~1.gbp2b32f6) ...
/var/lib/dpkg/info/php7.1-fpm.postinst: 2: /etc/apache2/envvars: =/var/run/apache2: not found
dpkg: error processing package php7.1-fpm (--configure):
 subprocess installed post-installation script returned error exit status 127
Setting up libapache2-mod-php7.2 (7.2.7-1+0~20180622080852.23+jessie~1.gbpfd8e2e) ...
/var/lib/dpkg/info/libapache2-mod-php7.2.postinst: 2: /etc/apache2/envvars: =/var/run/apache2: not found
dpkg: error processing package libapache2-mod-php7.2 (--configure):
 subprocess installed post-installation script returned error exit status 127
Setting up libapache2-mod-php7.1 (7.1.18-1+0~20180611145758.18+jessie~1.gbp2b32f6) ...
/var/lib/dpkg/info/libapache2-mod-php7.1.postinst: 2: /etc/apache2/envvars: =/var/run/apache2: not found
dpkg: error processing package libapache2-mod-php7.1 (--configure):
 subprocess installed post-installation script returned error exit status 127
dpkg: dependency problems prevent configuration of php7.2:
 php7.2 depends on libapache2-mod-php7.2 | php7.2-fpm | php7.2-cgi; however:
  Package libapache2-mod-php7.2 is not configured yet.
  Package php7.2-fpm is not installed.
  Package php7.2-cgi is not installed.

dpkg: error processing package php7.2 (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports is reached already
                                                              Errors were encountered while processing:
 php7.1-fpm
 libapache2-mod-php7.2
 libapache2-mod-php7.1
 php7.2
E: Sub-process /usr/bin/dpkg returned an error code (1)

How can I fix this?

asked Jul 3, 2018 at 14:07

Nazarko's user avatar

3

This commands helps me:

1) Remove PHP and all his libraries and files

sudo apt-get purge php7.*

2) Install PHP again

sudo apt-get install php7.2

answered Sep 20, 2018 at 20:09

Nazarko's user avatar

NazarkoNazarko

2441 gold badge4 silver badges14 bronze badges

2

It seems there’s a bug in the php7.1 for the Ubuntu distribution: https://bugs.launchpad.net/ubuntu/+source/php7.1/+bug/1710007

The issue can be fixed running the following commands before installing «libapache2-mod-php7.1»:

sudo apt-get remove --purge php* -y && apt-get purge libapache2-mod-php* -y

answered Jul 12, 2021 at 9:02

xserrat's user avatar

When you Install Software on Linux System you may Face a Number of Error Code. Here are Solutions to Fix All Application Installation Error on Linux PC.

Everyone faces a ton of errors and difficulties when we migrate to a new environment/operating system. The errors may vary from app installation errors to common usage errors.

Errors are pretty common when you shift from a full GUI-based operating system to a semi-command-based operating system like Ubuntu. In the Linux community, there is a saying, if you don’t get any errors while using Linux, this means that you are not properly using the system.

Linux OSs like Ubuntu and Mint is considered as one of the easiest Linux as you can do everything with the graphical user interface. But OSs like Arch Linux are totally command based unless you are using any desktop environment.

We, in this article, tried to cover the widespread errors and their solutions in as simple as possible straightforward methods/steps. Follow carefully and let us know whether you ended in solving the error or not.

Fix All Application Installation Error in Linux

Here are the Best Solutions to Fix Various Types of Software Application Installation Error on Linux PC System

Error Type 1: sub-process /usr/bin/dpkg returned an error code (1)

This is one of the common errors Ubuntu or any Debian based distros faces while installing any software package from either terminal or software center.

sub-process :usr:bin:dpkg returned an error code (1)

This is one of the examples we encountered while updating the Chrome Stable package. This means either the corrupt or broken.

Fix 1: Reconfiguring the dpkg package database

We are going to use a simple command to reconfigure the dpkg database, as this error may be caused due to any interruption while the installation.

$ sudo dpkg --configure -a

After executing this command, try the installation, and check if you are facing the same error or not. If yes then proceed to Fix 2.

Fix 2: Force Installation of the Package

Since the dpkg was not the issue, try this command to forcefully install the troublesome package.

We are going to show you two different commands, which actually work in a similar way, it will fix the broken dependencies to terminate the error.

$ sudo apt install -f

or

$ sudo apt install--fix-broken

Error Type 2: could not get lock /var/lib/dpkg/lock

This error can be encountered while using the apt-get command in the terminal. This error basically says us that the dpkg is not currently available to use. This can explain two things, there is already an app is being installed, or the app installation was interrupted in the middle of the process.

The error usually looks like this,

Could not get lock /var/lib/dpkg/lock – open (11: Resource temporarily unavailable)

E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?

or

E: Could not get lock /var/lib/apt/lists/lock – open (11: Resource temporarily unavailable)

E: Unable to lock directory /var/lib/apt/lists/

E: Could not get lock /var/lib/dpkg/lock – open (11: Resource temporarily unavailable)

E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?

Fix 1: Find and Kill the Process

In this method, we are manually going to find the process which is running and then will have to manually stop/kill the process(es).

First, use the following command to search the running process(es),

$ ps aux | grep [a]pt

or

$ pgrep -a apt

Now you have the process number, we are going to use the following command to kill the process,

$ sudo kill process_number

or

$ sudo kill -9 process_number

If you don’t search and figure out the process number/process id, use the following command to kill all the ongoing process(es),

$ sudo killall apt apt-get

Fix 2: By Deleting the Lock

In case, the above fix didn’t work in your case, we will try to delete the lock to get rid of the error, use the following command to do so,

sudo rm /var/lib/apt/lists/lock
sudo rm /var/cache/apt/archives/lock
sudo rm /var/lib/dpkg/lock

Execute these commands one by one, and cross verify the lock directory from the error itself and then use the rm command. For example, if your error contains /var/cache/apt/archives/lock, then only use the directory.

Error Type 3: add-apt-repository: command not found

This error is encountered when you are trying to add a new software from the PPA (Personal Package Archive) repository. PPA is one of the many ways that is used to install software into the Linux system.

We are first going to use the following command to update/sync the repository database,

$ sudo apt-get update

$ sudo apt-get update

If the execution completes without any error then only proceed to the next step.

Actually, add-apt-repository isn’t like the other command package found in Ubuntu/Debian systems, we are going to install the software-properties-common package to install the add-apt-repository.

$ sudo apt-get install software-properties-common

$ sudo apt-get install software-properties-common

Error Type 4: E: Unable to locate package

This is one of the errors I used to face whenever I use to try the apt-get or apt command to install any package. Well if we take a deep look into the error, the error is self-explanatory, that the system couldn’t find the package to install.

This error will look like this,

$ sudo apt-get install package_name

Reading package lists… Done

Building dependency tree

Reading state information… Done

E: Unable to locate package package_name

Now, the error is self-explanatory, but is it the same case with the solution too? I am worried to say that it is not.

Fix 1: Check Package Name

We are going to start with a simple solution, check for typos, spelling mistakes, if this is not the case with your situation, then we will have to look for other solutions.

Fix 2: Check the Compatibility of the Package

Now, we are going to check whether the package is available for your version of Ubuntu or not.

Use the following command to check your Ubuntu Version (Release and Codename),

$ lsb_release -a

Now, we know the release and codename of our Ubuntu (In our case 20.04 Focal), we will head to the Ubuntu Package Manager Website.

Scroll down to the search section, and search the package you were trying to install,

search the package you were trying to install

If the package is not available in the repository, then it is not possible to install that package on your Linux machine.

Error Type 5: Failed to download repository information

Many new Linux users prefer the GUI based Software Center to install new applications/software. This “Failed to download repository information” error is encountered in that Software Center only.

The error looks like this,

Failed to download repository information

As you can see that the error also says to ‘Check your internet connection’, but it is weird as the internet is perfectly working.

In this case, the only solution is to update the apt repository and observe the result to figure out the original error that is occurring that pop-up.

$ sudo apt update

$ sudo apt update

In the above result, see the last two lines of the result, it can be different in your case, note that error and comment below, we will be more than happy to help you out. Also, alternatively, you can search for that error in any Ubuntu community to see the solution to that particular error.

Error Type 6: Failed to download package files

This is another similar error to the above ‘Failed to download package files’ error, but the good thing about this error is that it is solvable.

Failed to download package files

The error says that the new version of the already installed software is available but it is not available to that particular mirror, so we will have to connect to the main server to update the issue.

For connecting to the main server, open Software & Updates and select the Main server from the drop-down menu of the ‘Download from’ label.

open Software & Updates and select the Main server from the drop-down menu of the 'Download from' label

Conclusion: Fix all Linux App Install Errors on your Unbuntu System with this detailed guide listed above. If you have any query please comment below 🙂

If you’ve any thoughts on How to Fix All App Installation Errors in Linux?, then feel free to drop in below comment box. Also, please subscribe to our DigitBin YouTube channel for videos tutorials. Cheers!

While there are various ways to install applications in Ubuntu, I prefer to use the apt command in the terminal for installing software.

If you do the same, you may come across a dependency error like this:

Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 green-recorder : Depends: python-urllib3 but it is not installable
E: Unable to correct problems, you have held broken packages.

Usually on It’s FOSS, you’ll find simple and easy to follow solutions to complicated problems. Unfortunately, this one is not that straightforward.

In this troubleshooting article, I’ll tell you why this error occurs and give some pointers on how to go about solving this issue.

Why do you see the “you have held broken packages” error?

Broken Package Error Ubuntu

You were trying to install an application package, most probably from a PPA or third-party repository.

Applications often need specific versions of libraries and software component (called dependencies). These dependencies may not be part of the application package itself, but they are expected to either be installed on your system already or installed during the installation of the application.

Your Linux system tries to install these dependencies on its own. But if the dependency package version is not available on your system, it gets confused as it has no way to solve this dependency problem.

This is why it informs you that the software you were trying to install depends on XYZ but this XYZ cannot be installed.

Another usecase is when your package can be held is when you try to install two versions of the same software. Say you are installing a specific version of Wine when you have another one installed already.

How to go about fixing the “Unable to correct problems, you have held broken packages” error

You can try a few things to make things work. You need to have some ideas on installing/removing packages in Linux command line to work things out here.

Make sure that your system’s package cache is updated

First, make sure that local package cache is updated. Your system checks this cache for the available packages. It’s possible (but not certain) that the dependency package is seen by the system after the cache update.

sudo apt update

Try installing the troublesome package again and see if it fixes the problem.

Install the dependency

If you try to install the troublesome package again and it still complains about the same dependency error than perhaps that dependency is not available for distribution version.

You may use the apt search command see if you could this library from some other package or name:

sudo apt search package_name

If the package is available, is it the same version as requested by the package you were trying to install?

Try to install the dependency package and see what happens:

sudo apt install dependency_package

You may encounter a dependency chain. You try to install dependency A but it complains of B. Then you try installing B and it complains of C.

It may also happen that when you try to install package C, it is already installed. Check the version of package C. Is it the same version as required by package B? If yes, then removing C and installing it again could help.

Can you get the missing dependency package from some other source?

If the missing dependency package cannot be found on your system (no results in apt search), you may try to get the dependency package from some place else. I know that’s not very convenient thing to do but you don’t have many options here.

For example, in the case of installing shutter, it complained about libgoo-canvas-perl and this library is no more available on Ubuntu system.

sudo apt install shutter
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 shutter : Depends: libgoo-canvas-perl but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

However, since it was available in the previous versions of Ubuntu, I looked for this package on Ubuntu’s package archive and found it under the listing of Ubuntu 14.04 here. I downloaded the .DEB file and installed it.

Now that this dependency package is installed, trying to install the original application (shutter in this case) should not complain about at least this package anymore.

If you cannot find the dependency package anywhere, install the troublesome package from some other source

So in the example above, I tried to install Green Recorder application using its PPA. This application needs python-urllib3 library but unfortunately, this library is not available in my Ubuntu 20.04 system.

[email protected]:~$ apt search python-urllib3
Sorting... Done
Full Text Search... Done

Clearly, this is a poorly packaged application. The developer made it available for Ubuntu 20.04 without realizing that Ubuntu 20.04 doesn’t support Python 2 anymore and all the Python libs now start with python3 prefix. So the python-urllib3 should be python3-urllib3.

If you are in such a situation, maybe check the project’s homepage or search on the internet for an alternate source for installing it. Perhaps there is a Snap/Flatpak version or some user created a PPA for it? If nothing else, you may go with source code option as well.

If you see the held broken package error during update try this

Most of the discussion so far assumed that you see this error while installing a new application. That may not always be the case.

If you see this error when you try updating your system with sudo apt update command, then you’ll have to take a slightly different approach.

First, check which package is being held with this command:

dpkg --get-selections | grep hold

If you see some packages being held, remove them and then go on updating your system or installing the software.

You may also use Synaptic package manager for fixing the broken packages.

Did you manage to fix the issue?

As I had mentioned earlier, there is no straightforward fix for this problem. You’ll have to investigate on your own and see if it can be fixed or not.

Please share in the comments if your problem gets fixed. If not, I may try to help you out.

Понравилась статья? Поделить с друзьями:
  • Uc3 ошибка частотника
  • Ubuntu error unmounting
  • Ubuntu файловая система доступна только для чтения как исправить
  • Ubuntu error the following packages have unmet dependencies
  • Ubuntu проверка системы на ошибки