Solved Can not install package list on new install

Solved issue

sofasurfer

Active Member
Joined
May 24, 2022
Messages
153
Reaction score
56
Credits
1,279
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?
 
Last edited:


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:
Code:
apt install abcm2ps

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.
 
Last edited:
You didn't say which Linux os you are running and what version.

My old list had 1600 lines. My new list that I am trying to install contains 2200 lines.

Installing old packages, their libraries and older dependencies on a fresh installation doesn't always go well.

For example Ubuntu and Debian both use and have 'Blueman' (the bluetooth management utility) installed.

Code:
/usr/lib/python3/dist-packages/_blueman.cpython-310-x86_64-linux-gnu.so

However, the older version of 'Blueman' in Ubuntu 20.04 Focal Fossa (tho it's still supported), may not be the exact same version that the dev's compiled for the most current release of 'Blueman' for Ubuntu 22.04 Jammin Jellyfish.
 
$ sudo apt install < Desktop/APTpackagelistIt'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.
I see your point and I will try this later today. It looks like this is the issue. But I want to say...many(many) years ago (if I'm not mistaken) the commands
Code:
  $ sudo apt list --installed > APTpackagelist
and
Code:
  $ sudo apt install < Desktop/APTpackagelist
did work without modification of the list. They must have changed the command to include more info in the list. Does anyone remember this from many years ago?

BTW Alexzee...I am running Ubuntu 20.04. Everything was up to date and upgraded.
 
The command
Code:
  dpkg -l | awk '/^ii/ {print $2}' > fileOfInstalledPkgsNameOnly
did indeed produce the proper list of packages as you stated. I also deleted the first line (Listing...) and resaved it. I will let you know, when I reload the list into my new system, how it went.
 
After saving my package list using
Code:
 dpkg -l | awk '/^ii/ {print $2}' > fileOfInstalledPkgsNameOnly
I got a list like this
Code:
alsa-utils
amd64-microcode
anacron
apache2
apache2-bin
apache2-data
apache2-utils
apg
app-install-data-partner
apparmor
appmenu-gtk-module-common
apport
apport-gtk

Next I tried to install the list and I got
Code:
Inspiron-660:~$ sudo apt install < Desktop/fileOfInstalledPkgsNameOnly
Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 5 not upgraded.

Why did nothing happen?
 
What happens if you put xargs in front of it?

Let's try:

xargs -a ~/Desktop/fileOfInstalledPkgsNameOnly sudo apt install
 
Try one of these:

Code:
sudo apt-get -y install $(cat fileOfInstalledPkgsNameOnly)

xargs sudo apt-get -y install < fileOfInstalledPkgsNameOnly

sudo apt-get install package_name1 package_name2 package_name3 package_name4 ...

while read -r line; do sudo apt-get -y install "$line"; done < /fileOfInstalledPkgsNameOnly

The -y keeps things installing, but you could try without it, and could use apt instead of apt-get.
 
Sorry to sound like a broken record here. You said : "
My old list had 1600 lines. My new list that I am trying to install contains 2200 lines.
Did you perform an upgrade on your already installed Ubuntu 20.04 system?

Many times helping in the Linux forums I've seen this over and over again that things are not a smooth transition with upgrades. The difference in your list is 600 packages and most likely a boat load of dependencies.

In post #6:
The cmd-line returned:
Code:
0 upgraded, 0 newly installed, 0 to remove and 5 not upgraded.

FWIW, I've been running Slackware for 10 years and this distro doesn't do dependency resolution.
Having a good experience with installing packages manually and installing all of the dependencies manually in the order in which they have to be installed before the actual program/pkg that I need/want installed is/has been a good recursive practice for me.

It looks to me (and I could be wrong) like the upgrade wasn't a complete success. APT is having trouble finding what it needs.
I'm basing that on 0 to rm and 5 not upgraded.

And if I am wrong kindly show me where I am so I can learn. Thanks
Alex
 
I started from scratch again. I reinstalled my base system and now am in the process of trying to load my package list.
1. Reinstall base.
2. update sources list.
3. Upgrade packages.
4. ran $ sudo apt-get -y install $(cat packagelistwithversion). Error said to many arguments. Google said that means trying to load a package list 100s of packages can't be done. I would need to break list into smaller sections.
5. Ran
Code:
while read -r line; do sudo apt-get -y install "$line"; done < packagelistwithversion
This appeared to work and ran a long time but no packages were added. Here is the last few lines of the output
Code:
E: Release 'focal,focal,now 3.36.0-1 all [installed,automatic]' for 'yelp-xsl' was not found
Reading package lists... Done
Building dependency tree      
Reading state information... Done
E: Release 'focal-updates,now 3.36.2-0ubuntu1 amd64 [installed]' for 'yelp' was not found
Reading package lists... Done
Building dependency tree      
Reading state information... Done
E: Release 'focal,focal,now 3.32.0-5 all [installed,automatic]' for 'zenity-common' was not found
Reading package lists... Done
Building dependency tree      
Reading state information... Done
E: Release 'focal,now 3.32.0-5 amd64 [installed]' for 'zenity' was not found
Reading package lists... Done
Building dependency tree      
Reading state information... Done
E: Unable to locate package zim
Reading package lists... Done
Building dependency tree      
Reading state information... Done
E: Release 'focal,now 3.0-11build1 amd64 [installed]' for 'zip' was not found
Reading package lists... Done
Building dependency tree      
Reading state information... Done
E: Release 'focal-updates,focal-security,now 1:1.2.11.dfsg-2ubuntu1.5 amd64 [installed,automatic]' for 'zlib1g' was not found
Does this mean that I am lacking proper sources?
I can post the entire output if you want me to.
 
sofasurfer asked:
Does this mean that I am lacking proper sources?
Yes, check your sources.list file to see that it's accessing the repositories you need. The packages not found in the output, like zenity and yelp, are actually packages that are expected to be in the standard repositories.
 
I got it!
My problem was that I tried to install a package list that included the version information like this
Code:
  apache2-bin/focal-updates,focal-security,now 2.4.41-4ubuntu3.14 amd64 [installed,automatic]
. I needed to use a list that included ONLY the package name like this
Code:
 apache2-bin
The actual full code I used to install the package list is
Code:
  $ while read -r line; do sudo apt-get -y install "$line"; done < packagelistnamesonly
 

Members online


Top