1

So far, it seems that the best way to install packages without losing your head on Linux is to use apt-get install <package>. This is because the command pulls all dependencies along with it. If I choose to stick with dpkg --install <package> for installing packages on my machine, which means I probably downloaded the package – how can I ensure that I do not miss any dependent packages?

For things like libelf-dev or libelf1, are there websites that carry source disk containing these nice-to-haves, and in fact carry bundled modules to make updates easier? Again, so I don't miss the packages that libelf needs, like make, etc.

4
  • Use libelf from Debian repositories also! There's no need to compile it manually. Jun 25, 2018 at 23:10
  • 3
    And why exactly using apt-get install is not good enough? What do you gain by doing all the dependencies resolving by hand and using dpkg? Jun 25, 2018 at 23:15
  • @PatrickMevzek what happens with purely using apt-get install at times is somethings will break. Most notably as Ubuntu 14.04LTS and python2 were going out of support, I for example found myself missing things like pip when they were previously available. This is easy to understand, but in the past I have had the apt-get install break for no reason (probably I started something with dpkg and it clogged the pipeline) which I personally think that you are correctly alluding to - this should be a winning command. A noob on dpkg should present more errors (the problem).
    – Phume
    Apr 20, 2020 at 7:20
  • Over experience I have found that apt-get automatically presents solutions such as apt-get -f install, which it suggests after package breaks. Thanks though.
    – Phume
    Apr 20, 2020 at 7:20

4 Answers 4

2

You always need to satisfy the dependencies, that is why they are called like that.

That said, the best method of installing a downloaded .deb package IMHO is:

sudo apt-get install ./some_package_name_in_current_directory.deb

Of course, you can always go the other way around like so:

sudo dpkg --install ./some_package_name_in_current_directory.deb
sudo apt-get install --fix-missing

But I find it cumbersome.

3
  • you are right, if you follow my logic when you try to install some packages, say you download them manually at some url you get the initial file that you think that you need. But, when you read the rest of what I mean here by dependencies... on that website termed "requires"/requirements-to-run the intended package. You can find that you at times even enter into a seemingly endless loop to find the rest of the modules that your targeted module needs to work! The question is how do I force either dpkg or apt-get to do the work for me!?
    – Phume
    Apr 20, 2020 at 7:22
  • Over experience, it would seem as though apt-get does not work as you suggested. But dpkg does, and is the main source of the problem. If you are lucky, you can read through the error messages until you get it right. But the question is can I do it more seamlessly so as I don't miss a thing? On a good day, apt-get should the work for you. But at times, I start out with dpkg and try to force apt-get to finish the work for me as it could be a file that is still carried in the ubuntu source repos. I must have asked the question before I fully understood what was happening as well.
    – Phume
    Apr 20, 2020 at 7:23
  • ... apt-get does not work that way "./install.deb". Only dpkg does.
    – Phume
    Apr 20, 2020 at 7:26
0

IIRC if you have a .deb file with dependencies that can be met from your configured repos, you can install it with dpkg -i package.deb and then do an apt-get -f install and apt will bring in anything that your package needed... but ONLY if appropriate version numbers, etc. all exist and match.

0

There is a way to do this. It is really not recommended, but i have found it useful when i needed to install a package that has been abandoned, when the bugs that exist in it do not stop me from performing my tasks (for example if the package provides several binaries, but i only require one of them).

Let's say you have a file package.deb. You do the following:

ar t package.deb

You then look for a file that is starts with data, most commonly it will be data.tar.xz, but a different compression can sometimes be used (or so i read).

Then you run

ar x package data.tar.xz

Make sure to confirm that the extraction took place, because there will be no output one way or another.

It may be beneficial to move the data file to some directory all by itself, because on the next step we will be extracting a directory tree, and you don't want to try to figure out what you need and what you don't need after you finish.

Now extract the file you got:

unxz data.tar.xz
tar xvf data.tar

You will find files that would be created by installing the package, but with the current directory as the root. So if the binary would go into /usr/bin, you will find it in ./usr/bin.

After this you can manually copy the files into their correct places. Or i prefer to copy them into the /home/user/bin and add a that directory to PATH. This way you have a little less chance to break the system. Of course if you are installing a library package you will need to spend some more time figuring out what goes where.


Once again, this is not the best way to install packages (to say the least). This installation makes it difficult to remember which file was from what package, and thus it is difficult to figure out where some error is coming from. But unfortunately there are times when you need to "Just Fucking Do It" (tm).

0

After considering other people's responses, I think that the best and most wholistic answer is, there are ONLY three (3) ways to install packages on Linux. AND, ONLY ONE of them ensures that all dependent packages are installed automatically. These are:

apt-get install <package-name>

Which is the one! Then;

dpkg --install <full path to package/package-name.deb>

And, the last is to build everything from source. This last option is almost no different from using dpkg. Only, you might have to do some extra work to understand "autoconf, automake, and the like" to get going. But, most sources come with the automake configure file created and at most you have to run ./configure to suit the package to your PC architecture, make and make install! That is it!

Finally, in response to my question(s), it means if one wishes to use the last two, it is up to you/them to use well kept websites like packages.ubuntu.com or other to track all the dependencies, and recommended packages. Then, install the downloaded dependencies as needed, for each of the packages will eventually to install (manually). The sources typically say things like make sure you have build-tools installed. Of which you can respond to by mixing install methods i.e. apt get install build-tools which is found in the Ubuntu repos and then run make install for the sources in question. Thus, skipping having to track and download build-tools and its dependencies manually.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.