Skip to main content
Photo by Gabriel Heinzer via Unsplash

Fixing package dependency issues on Ubuntu with APT

Have you ever tried installing a program on your Ubuntu and ran into error messages about unconfigured dependencies? Don’t worry; it happens to the best of us. For example, when you install a program, it might rely on other software packages to run correctly; if those dependencies are not met, the program won’t work.

The following happened today when I tried to install Local (a program that allows you to run a local WordPress on your computer):

 1$[patrick@main]~❯ sudo dpkg -i Downloads/local-6.6.1-linux.deb
 2Selecting previously unselected package local.
 3(Reading database … 245182 files and directories currently installed.)
 4Preparing to unpack …/local-6.6.1-linux.deb …
 5Unpacking local (6.6.1-20230202.4) …
 6dpkg: dependency problems prevent configuration of local:
 7local depends on libncurses5; however:
 8Package libncurses5 is not installed.
 9local depends on libnss3-tools; however:
10Package libnss3-tools is not installed.
12dpkg: error processing package local (--install):
13dependency problems - leaving unconfigured
14Processing triggers for mailcap (3.70+nmu1ubuntu1) …
15Processing triggers for gnome-menus (3.36.0-1ubuntu3) …
16Processing triggers for desktop-file-utils (0.26-1ubuntu3) …
17Processing triggers for hicolor-icon-theme (0.17-2) …
18Errors were encountered while processing:

The interesting thing to note is that the program (in this case, local) was NOT fully installed. It was installed, but some dependencies were left uninstalled, and the program was not configured correctly.

What to do now?

The good news is that fixing this issue is easy with the sudo apt install -f command. This command checks for any broken dependencies in the package management system and automatically fixes them. Let’s break down what each part of the command does:

  • sudo: The sudo command runs the command following with administrative or root privileges.
  • apt: The apt command is a package management utility in Ubuntu and other Debian-based Linux distributions used to manage software packages.
  • install: The install command is used to install packages.
  • -f: The -f option stands for “fix” and is used to fix broken dependencies in the package management system.

When you run sudo apt install -f, the command will check for any missing or broken dependencies and attempt to fix them automatically. Afterward, it sets up all unconfigured packages. This can help ensure that your system runs smoothly and that all the necessary software packages are installed correctly.

Here’s an example of running sudo apt install -f on my system that had broken dependencies after the command above:

 1$[patrick@main]~❯ sudo apt install -f
 2Reading package lists… Done
 3Building dependency tree… Done
 4Reading state information… Done
 5Correcting dependencies… Done
 6The following additional packages will be installed:
 7libncurses5 libnss3-tools libtinfo5
 8The following NEW packages will be installed:
 9libncurses5 libnss3-tools libtinfo5
100 upgraded, 3 newly installed, 0 to remove and 15 not upgraded.
111 not fully installed or removed.
12Need to get 771 kB of archives.
13After this operation, 3,074 kB of additional disk space will be used.
14Do you want to continue? [Y/n]
15Get:1 jammy/universe amd64 libtinfo5 amd64 6.3-2 [99.2 kB]
16Get:2 jammy/universe amd64 libncurses5 amd64 6.3-2 [107 kB]
17Get:3 jammy-updates/universe amd64 libnss3-tools amd64 2:3.68.2-0ubuntu1.2 [565 kB]
18Fetched 771 kB in 1s (756 kB/s)
19Selecting previously unselected package libtinfo5:amd64.
20(Reading database … 246447 files and directories currently installed.)
21Preparing to unpack …/libtinfo5_6.3-2_amd64.deb …
22Unpacking libtinfo5:amd64 (6.3-2) …
23Selecting previously unselected package libncurses5:amd64.
24Preparing to unpack …/libncurses5_6.3-2_amd64.deb …
25Unpacking libncurses5:amd64 (6.3-2) …
26Selecting previously unselected package libnss3-tools.
27Preparing to unpack …/libnss3-tools_2%3a3.68.2-0ubuntu1.2_amd64.deb …
28Unpacking libnss3-tools (2:3.68.2-0ubuntu1.2) …
29Setting up libtinfo5:amd64 (6.3-2) …
30Setting up libnss3-tools (2:3.68.2-0ubuntu1.2) …
31Setting up libncurses5:amd64 (6.3-2) …
32Setting up local (6.6.1-20230202.4) …
33Processing triggers for man-db (2.10.2-1) …
34Processing triggers for libc-bin (2.35-0ubuntu3.1) …

Long story short: if you ever encounter any unconfigured dependencies while installing a program on Ubuntu, just remember to run sudo apt install -f, and you’ll be good to go.

Back to top
Back Forward