How to install local .deb packages with apt-get

149

32

Is there a way to install packages store on your HD with apt-get, like apt-get install ./package.deb?

If not, how to handle the dependencies in a very very easy way?

Louis

Posted 2010-10-07T08:02:24.980

Reputation: 2 074

This works now. If you still use SuperUser, can you update the accepted answer? See below. – mikemaccana – 2019-07-05T15:47:38.377

Answers

124

usually I do dpkg -i <deb file>, it'll fail saying it needs dependencies. After that when you do an apt-get update it'll say at the end something like "dependencies are ready to install" I think it then advises to use apt-get install -f.

Once that's done, I use dpkg -i again.

Worked fine for me last few years.

edit: looking a bit further, apparently a tool called gdebi can do this as gdebi [deb file].

Sirex

Posted 2010-10-07T08:02:24.980

Reputation: 10 321

2gdebi is worked for me, and simplest I have seen so far. – ctrl-alt-delor – 2016-08-18T15:00:55.813

1Thanks i did the same by "error" dpkg then apt-get install -f and it worked. – Louis – 2010-10-07T08:22:48.120

56

Sirex has it more or less correct, but his answer isn't clear. I just solved this, so here's what I did:

sudo dpkg -i /path/to/filename.deb

If this fails with a message about the package depending on something that isn't installed, you can probably fix it if you run

sudo apt-get -f install

This will install the dependencies (assuming they're available in the repos your system knows about) AND the package you were originally requesting to install ('f' is the 'fix' option and 'y' is the 'assume yes to prompts' or 'don't ask me if it's ok, just install it already' option -- very useful for scripted silent installs). On the system I was on, there was no need to run dpkg again (Ubuntu lucid 10.04).

I found it interesting that if you leave off the -f when you run sudo apt-get install, it will list your package as not being configured due to an unresolved dependency as well as helpfully suggesting: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

Edit:

If you want install without having to answer 'y' to all of the questions, you can add the y modifier as I originally included: sudo apt-get -fy install. However, a commenter pointed out that apt will sometimes suggest that you uninstall your entire desktop environment. I was doing this work in a VM and didn't have that concern, but this post has been updated to reflect being a bit more careful.

Akrikos

Posted 2010-10-07T08:02:24.980

Reputation: 679

2For you own good, do not add the -y option. It is quite common for apt to suggest, for example, uninstalling your whole desktop environment if you try this with the wrong package at the wrong time (at least on Debian). – oseiskar – 2014-09-05T14:39:53.457

If I have all the package files already in a directory, is there a way to tell apt that this is a new repository, so i won't have to force it installing anything without dependencies? – Berry Tsakala – 2013-03-04T13:33:47.797

2I'm sorry, but I don't know. I'd suggest asking that as another top level question. – Akrikos – 2013-03-12T18:56:56.047

Crazy strange that this is required. On raspian, this will require sudo (for both dpkg and apt-get): sudo dpkg -i mypackages.deb, etc. – Brent Faust – 2013-08-16T00:53:31.847

@Rubistro root access it required on all systems. I guess the answers assumed that that commands are executed by root (e.g. from an interactive root shell, or a script which executes as root). – Amos Shapira – 2014-01-05T19:34:03.803

45

You can also install .deb file using gdebi.Run the below commands to install gdebi,

sudo apt-get install gdebi-core

Install .deb packages with gdebi,

sudo gdebi /path/to/filename.deb

It also fix dependencies.

Avinash Raj

Posted 2010-10-07T08:02:24.980

Reputation: 735

4Note that gdebi only takes a single argument and silently drops the rest on the floor. This means if you're installing multiple debs at the same time (perhaps because they depend on each other) you'll need to carefully craft gdebi commands which allow them to install. imo this half defeats the purpose of gdebi, but you may still find it useful for a single file – Anthony Sottile – 2015-07-15T02:58:16.350

@Anthony then find -name *.deb -exec gdebi {} \; – jjmontes – 2015-07-25T16:40:15.907

3@jjmontes that'll only work if the interdependencies are in alphabetical order which I'd wager is pretty rare – Anthony Sottile – 2015-07-26T15:34:14.773

I followed this http://freesoftwaremagazine.com/articles/debianubuntu_making_package_repository_your_lan/ (bug the local repo had to be at /var/www/html/debs) and synaptic kept trying to download from remote even w/o internet, so gdebi worked great with the local repo! also, the .deb files had to be chmod +r *.deb

– Aquarius Power – 2018-07-13T23:36:10.627

42

Yes, the command you proposed is correct.

sudo apt-get install ./package.deb

or

sudo apt install ./package.deb

will install the package you got from another source than APT and same time use APT capabilities to resolve its dependencies automatically. Unfortunately, this apt-get feature is not documented in the man page.

See https://askubuntu.com/a/769542/250300 and https://askubuntu.com/a/795048/250300 for details.

Melebius

Posted 2010-10-07T08:02:24.980

Reputation: 1 145

10This should have been the accepted answer. – Peter – 2018-05-16T06:57:40.060

Which version of apt-get added this capability? – Kurt Fitzner – 2018-12-24T04:28:19.857

1

@KurtFitzner It was added in APT 1.1 per release announcement (found via https://askubuntu.com/a/795048/250300).

– Melebius – 2019-07-09T19:54:10.700