Sometimes, after apt-get install zip unzip I get this message:
Reading package lists…
Building dependency tree…
Reading state information…
Package zip is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package ‘zip’ has no installation candidate
ERROR: Job failed: exit code 1
This is an erratic error. Not always happens. Usually the error happens in the first try. Then, I click retry and it runs properly after. Any ideas?
I found an image that had the software I needed installed. I insalled zip to unzip the installer of the software. Now, my image has it directly. You can search images at https://hub.docker.com/
Hello, the install step needs the option -y, otherwise you would get a prompt only if zip is not installed already. And you better „export DEBIAN_FRONTEND= noninteractive“ as well beforehand.
Unfortunately in german. The englisch summary:
add rm /etc/apt/sources.list.d/additional.list before the installation of the packages, as it sometimes uses the source from this file. And if it does, it fails.
This was the first link I saw when searching for my problem, so posting the solution here.
As it turns out, the list of the package sources in AWS is populated by cloud-init, which takes some time to run after the machine spins up. Now, the time is usually around 3-5 seconds so you can’t notice it when doing stuff manually, but if there’s some automation, and the first thing it does is apt-get update, you can get in trouble.
The solution is simple: wait for cloud init to finish. It’s got a helpful cloud-init status --wait command just for that.
So, overall, this should work:
cloud-init status --wait
sudo apt-get update
sudo apt-get install -y zip unzip