I saved a package list from my old system. I saved it with this command
Code:
$ sudo apt list --installed > APTpackagelist
I want to install it on my new system. I ran this command
Code:
$ sudo apt install $(< ~/Desktop/APTpackagelist)
I got this output
Code:
$ sudo apt install $(< ~/Desktop/APTpackagelist)
sudo: unable to execute /usr/bin/apt: Argument list too long
I googled the issue and came up with this solution
Code:
$ sudo apt install < Desktop/APTpackagelist
This did not work either. Here is the output
Code:
$ sudo apt install < Desktop/APTpackagelist
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
gir1.2-goa-1.0 libfprint-2-tod1 libfwupdplugin1 libllvm10 libxmlb1
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
My old list had 1600 lines. My new list that I am trying to install contains 2200 lines.
So why will the new list not install?
A few observations ...
When you run the command: "apt list --installed > APTpackagelist", you will likely get output resembling this:
Code:
[flip@flop ~]$ apt list --installed > fileOfInstalledPkgs
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
which lets you know that there may be a problem with the output being used for other commands, in particular it mentions scripts. One reason for that is the nature of the output, which looks like the following when viewing the top lines of the file which I'm taking as an example from a computer here:
Code:
[flip@flop ~]$ head fileOfInstalledPkgs
Listing...
abcm2ps/testing,now 8.14.14-1 amd64 [installed]
acl/testing,now 2.3.1-3 amd64 [installed,automatic]
adduser/testing,now 3.132 all [installed]
adwaita-icon-theme/testing,now 43-1 all [installed,automatic]
aiksaurus/testing,now 1.2.1+dev-0.12-7+b1 amd64 [installed]
alsa-topology-conf/testing,now 1.2.5.1-2 all [installed,automatic]
alsa-ucm-conf/testing,now 1.2.8-1 all [installed,automatic]
alsa-utils/testing,now 1.2.8-1 amd64 [installed,automatic]
anacron/testing,now 2.3-36 amd64 [installed,automatic]
If no processing is done to the lines on this file, apt will be unable to install anything because there's too much information on the lines for apt to read. Hence, in the case you describe, there was the error message: "unable to execute /usr/bin/apt: Argument list too long."
Looking at the output of the "apt list --installed" command, it is clear what apt is complaining about. Take for example the second line:
Code:
abcm2ps/testing,now 8.14.14-1 amd64 [installed]
apt is seeing the name of the program as "abcm2ps/testing,now" with arguments after it which it detects as "8.14.14-1", "amd64", "[installed]". The program itself however is named "abcm2ps", and needs no arguments for it to be installed by apt. The installation command would be:
Given that apt only wants the name of the program to install, then if one is to use the output of the command: "apt list --installed", one would need to strip off all the extra strings and alpha numerics after the actual name of the package. And one would also need to eliminate the heading "Listing ..." from that file since that's not a package to be installed.
It's possible to get a list of installed packages on a system which just includes the name of the program, for example:
Code:
dpkg -l | awk '/^ii/ {print $2}' > fileOfInstalledPkgsNameOnly
The output is like this:
Code:
[flip@flop ~]$ head fileOfInstalledPkgsNameOnly
abcm2ps
acl
adduser
adwaita-icon-theme
aiksaurus
alsa-topology-conf
alsa-ucm-conf
alsa-utils
anacron
ansiweather
This list matches the earlier list of installed packages, but may be more usable for installation purposes.