How to install dependencies linux

How to install dependencies with apt?

What are dependencies?

Dependencies are files or components in the form of software packages essential for a program to run properly. This is the case with Linux overall – all software depends on other pieces of code or software to function correctly. So, this sort of “sectional” approach is where dependencies originate from. They are additional but essential pieces of code that are crucial to making programs work. This also explains why we get dependency errors during program installations as the programs being installed depend on other, missing code.

What is APT?

In the domain of Linux and, more specifically, Ubuntu, APT is short for Advanced Package Tool. It is the primary user interface that comes equipped with libraries of programs pertinent to software package management in Linux distributions such as Ubuntu and Debian.

Then comes the apt command, which is the most common way of interfacing with the Advanced Package Tool. Ubuntu users use apt to install new software, update and upgrade not only existing packages but also the entire operating system. This is what makes apt a very powerful and commonly used command in Ubuntu. Furthermore, the abilities of the apt command are not limited to just installing software packages, as it also plays a very important role in handling dependencies.

When downloading dependencies, we use the apt-get command. The primary function of apt-get is to obtain software packages and information from their respective repositories. The sources of these packages are authenticated and secure. The same procedure works for updating and removing dependencies.

Installing dependencies

Now, let us finally get into using the apt-get command and start installing dependencies. But before that, it is important to learn what the syntax of this command is.

The syntax described above is the most commonly used ones; however, there are some other ways to call this command.

Another method to use apt-get is as follows.

With that being said, you should now have a good general understanding of how apt-get works and how you can use it to install dependencies. The next step is to start looking at practical instances of its usage to see how we can use different command variants to manipulate dependencies.

Let us suppose that you want to install Python on your Ubuntu system. The first thing you would need before you install Python is a dependency known as libpython2.7-minimal. So, you can run the command below to get it.

(You may need to enter Ubuntu as root, so run $ sudo -i)

The output shows that the required package has been retrieved, extracted, and configured. We also get the amount of storage space the package is consuming. If any missing packages are remaining, we can simply run the command below to install those as well.

Now that all the dependencies are taken care of, we can install Python with the traditional command as follows.

That pretty much covers how you can install dependencies in Ubuntu; however, there are other ways you can manipulate them as well. We will cover these in the next section.

Additional Information

Let’s say, for instance, you wish to remove the dependency we just installed. You can do that by executing the following command.

You can run an apt command to update all the packages on your system. This is generally considered good, precautionary practice before proceeding with regular processes. It makes sure that all of your dependencies are met and updated.

Next, we will see how one can list all the packages on their system by running an apt command. The output of this command will display to us a long list of software packages that are available for installation.

Читайте также:  Linux для ноутбука установка с флешки

However, you may want to install a specific package but not know which other dependencies need to be installed for it to work. Ubuntu fixes this issue through the showpkg flag. Run the command below to find out which dependencies are required.

Here, libslang2 is the initial package we wanted to install. In short, we can use the showpkg command to obtain more information on the dependencies we need for a certain package.

As we mentioned earlier, all the packages we install consume disk space, whether additional dependencies or the main programs themselves. Therefore, due to excessive dependencies, our computer can get cluttered. But worry not, as Linux has us covered in that department as well. You can simply run the commands given below to “clean” your dependencies.

In CentOS, the same operation is performed by the commands yum clean or yum cleanall. The clean flag clears all .deb files from the repository in var/cache/except for lock files. However, the autoclean flag also clears all the .deb files from the repository as mentioned above, but only the ones that have gone obsolete. These software packages are not available for download anymore.

Conclusion

In this article, we went into great detail about how one can install dependencies through apt. We first learned how dependencies work and why they are needed. Later on, we saw how one could install them and further manipulate them through other commands.

About the author

Zeeman Memon

Hi there! I’m a Software Engineer by degree, Blogger by skills who loves to write about tech, develop websites & do SEO. You can reach out to me on LinkedIn.

Источник

How to install missing dependencies of a custom Debian package?

A custom Debian package has this dependency in the Debian control file:

That must be downloaded from download.docker.com as it isn’t part of the official Debian repositories. The apt sources list looks like this:

Installing that custom Debian package fails:

I thought apt —fix-broken would install the missing docker-ce package from the third-party repository, but instead it wants to remove my foo package. The following works:

What I have tried so far:

2 Answers 2

To install a .deb package while downloading dependencies from the configured repositories, use

Do provide a path even if the file is in the current directory.

If the dependency still isn’t found, show us the output of apt-cache policy docker-ce .

It is well explained in this link.

I know 3 different ways to do it:

a) sudo apt install application.deb

it will install the package it with dependencies in one run automatically:

and if there is any dependencies for the packagename.deb , the command below should be invoke to resolve the dependencies:

c) sudo gdebi my_package_1.0.deb

if gdebi is not installed already, you may install it first. In order to find out if a package, like gdebi in our case, is installed or not, check the status of a package, you may issue the command below:

Источник

How to Install and Correct Dependencies Issues in Ubuntu

What is a Dependency?

A dependency is defined as a file, component, or software package that a program needs to work correctly. Almost every software package we install depends on another piece of code or software to work as expected. Because the overall theme of Linux has always been to have a program do one specific thing, and do it well, many software titles utilize other pieces of software to run correctly.

Introduction

Let’s review what dependencies are and why they are required. We all have, at one point or another, most certainly seen a message from our system when we were installing software regarding “missing dependencies.” This error denotes that a required part of the software package is outdated, unavailable or missing. Let’s review how to address those issues when we come across them on Ubuntu.

Install Dependencies

Ubuntu uses apt (or the Advanced Package Tool) for software package management. Most of the time, you will see the apt-get command used whenever you see the installation of something on Ubuntu. The main task of apt-get is to retrieve the information and packages from a repository with secure, authenticated software sources used to installation, upgrade, and/or removal of packages along with their dependencies.

Читайте также:  Драйвера для ноутбука dell inspiron 15 3000 series для windows 10 x64

This is the syntax of apt-get:

Now that we know what apt-get is and how the syntax for it should look like, let’s go through some of the most used apt-get commands, and we will explain how each of them manipulates dependencies.

Install Software

So let’s say that we want to install Python on our server. First, we would need to install a libpython2.7-minimal package/dependency. We can run this command to accomplish this.

We will get an output that the package itself has been found, unpacked and configured. Along with the info about disk space that package will take. If we are missing two dependencies, then we can just run a command like this to install those packages.

Now we can install python with pretty much the same command:

Removal Software

If we want to remove this dependency, we can run the following command.

This will remove libpython2.7-minimal package as well as all the associated dependencies it has.

Update Software

If at any point you want to update all the system packages on the server, we can simply run this command. This command updates all of our software including any dependencies.

The second command will list all software packages it wants to install/update and will prompt us with a yes or no option before proceeding with the installation. Using this command, we ensure all of our dependencies are met.

List Software

If you want to list all available packages, we can use this command.

We mention this command as it leads us into our next section specifically regarding dependencies. This command will show us a huge list of packages available for installation. Now, let’s say that we want to install the libslang2 package, but are unsure which dependencies need to be installed along with this package and which ones are not. We may not even know which ones we need. Luckily, Linux provides for this option by using the showpkg flag. We can run this command to see what dependencies are needed.

So, if we are not sure which dependencies we need, we can simply run the showpkg subcommand to get the information that we need.

Clean Dependencies

If you want to clear up some of the clutter that can sometimes take up our valuable disk space, we can use the following command to free up additional disk space.

These commands will get the job done for us in the same manner that the yum clean and yum cleanall commands do on CentOS.

The clean flag removes all the .deb files from the local repository in /var/cache except the lock files.

The autoclean flag also removes all the .deb files from the local repository, but unlike the clean flag, it removes only the obsolete packages that can no longer be downloaded.

Unmet Dependencies Errors

Almost every Ubuntu user has seen the error «The following packages have unmet dependencies issues«. In this circumstance, the failure almost always is related to the apt package manager as opposed to the software being installed. Luckily, there are multiple options available to rectify this situation. We will look at several ways to address this issue.

Backup Configuration Files

First, as with any system modification, taking a backup of our configurations is a must. We do this to ensure that is any additional issues crop up, we can revert the changes we have made to restore our system files.

Options

When these dependency errors occur, we have multiple options we can try to address the issue.

  • Enable all repositories
  • Update the software
  • Upgrade the software
  • Clean the package dependencies
  • Clean cached packages
  • Remove «on-hold» or «held» packages
  • Use the -f flag with the install subcommand
  • Use the build-dep command
  • Test install package
  • Reinstall the software
  • Remove the PPA

List Packages Using Apt-mark

As an aside, when the apt-mark showauto command is used, it prints a list of each package that will be automatically added on a new line. If a package name is given, only those packages that will be installed automatically will be shown. We mention this, so we can note the packages that should be installed with the software.

Option 1: Enable all Ubuntu Repositories.

Utilizing this option will allow for a wider base of software and dependencies to pull from. Then, once this is updated, we can try to reinstall the software.

Читайте также:  Windows 10 не удаляется язык ввода

Option 2: Update the Software

Once the above command has finished, we can try to update the package again. Trying to update the software should be our first line of defense.

Option 3: Upgrade the Software

Next, we can show the packages that need to be upgraded and then attempt to upgrade the software.

Option 4: Clean the Package Dependencies

A corrupted package database or packages that were broken or not installed properly can cause this problem. This option uses the autoremove flag to address this.

This command will remove only obsolete or unnecessary packages that no longer exist in the repositories.

Option 5: Clean Cached Packages

This command will clean up the local repository of downloaded packages. Then, try to reinstall the software.

Option 6: Remove «On-hold» or «held» Packages

To locate software that is held or on hold, we can use the apt-mark command. Once we have that info, we can use the remove and dry-run flags to see exactly what will be removed. Then, try to reinstall the software.

Option 7: Use the -f Flag

According to the apt-get man page, using the -f (or —fix-broken) parameter will allow the apt-get command to try to correct the broken dependencies issue. Do not use the package name in the command when using -f.

-f, —fix-broken
Fix; attempt to correct a system with broken dependencies in place. This option, when used with install/remove, can omit any packages to permit APT to deduce a likely solution. If packages are specified, these have to completely correct the problem.
The option is sometimes necessary when running APT for the first time; APT itself does not allow broken package dependencies to exist on a system. It is possible that a system’s dependency structure can be so corrupt as to require manual intervention (which usually means using dselect(1) or dpkg —remove to eliminate some of the offending packages).
Use of this option together with -m may produce an error in some situations. Configuration Item: APT::Get::Fix-Broken.

If you see the 0 upgraded message, this means this command has failed. We are not done yet, though. Let’s try to issue the command again.

Option 8: Use the Build-dep Command

Using this subcommand, we canВ install all the dependencies for ‘softwarename’. Then, we can try to reinstall the software dependencies individually.

Option 9: Test Install Package

The —dry-run flag shows us what apt-get would install without actually installing the package. This is useful with the above command. It can also sometimes show the dependency error prior to the software installation.

Option 10: Reinstall the Software

There are certain dependency issues and conflicts which arise that apt cannot solve. When this occurs, apt will save those packages in an ‘on-hold’ state. This means they will not have been completely installed. Removing those software packages may fix the problem and might assist in solving the original issue. The apt-get purge command will remove the program, all the associated configuration files, and any plugins or settings from our system.

If the output shows any packages in an “on-hold” state, we can go ahead and try to remove them. Once that command completes, run this command to

Now remove the held packages one at a time by executing dist-upgrade each time, until there are no more held packages. Afterwards, try to re-install your package. Make sure to implement the –dry-run option, in order to stay informed of the consequences:

Option 11: Remove Old PPA

The following commands remove the package, the PPA and the associated dependencies.

In the end, we can draw a conclusion that apt-get manages dependencies the same way that yum does. We can install dependency with the install subcommand, we can remove it with remove subcommand, update it with upgrade subcommand, and so on.

If you are using Ubuntu and looking for the best way to manage your dependencies and packages, apt-get is a way to go. It’s superior to dpkg, and it’s more user-friendly.

If you continue to have issues with this, give us a call at 800.580.4985, or open a chat or ticket with us to speak with one of our knowledgeable, experienced Linux administrators today!

Источник

Оцените статью