Score:2

Can't install snap the package manager

gl flag

Some time ago I uninstalled snap, and probably messed things up cause now I can't install it back. When I try to run sudo apt install snapd this error appears:

Package snapd 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 'snapd' has no installation candidate

My system specs:

neofetch

What should I do?

Ps. I tried:

sudo apt-get purge snapd
sudo apt-get install snapd

didn't work.

cat /etc/apt/sources.list displays this:

# deb cdrom:[Ubuntu 20.04.4 LTS _Focal Fossa_ - Release amd64 (20220223)]/ focal main restricted

# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://archive.ubuntu.com/ubuntu jammy main restricted
# deb-src http://it.archive.ubuntu.com/ubuntu/ focal main restricted

## Major bug fix updates produced after the final release of the
## distribution.
# deb-src http://it.archive.ubuntu.com/ubuntu/ focal-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://archive.ubuntu.com/ubuntu jammy universe
# deb-src http://it.archive.ubuntu.com/ubuntu/ focal universe
# deb-src http://it.archive.ubuntu.com/ubuntu/ focal-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu 
## team, and may not be under a free licence. Please satisfy yourself as to 
## your rights to use the software. Also, please note that software in 
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://archive.ubuntu.com/ubuntu jammy multiverse
# deb-src http://it.archive.ubuntu.com/ubuntu/ focal multiverse
# deb-src http://it.archive.ubuntu.com/ubuntu/ focal-updates multiverse

## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
# deb-src http://it.archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse


deb http://archive.ubuntu.com/ubuntu jammy-security main restricted
# deb-src http://security.ubuntu.com/ubuntu focal-security main restricted
deb http://archive.ubuntu.com/ubuntu jammy-security universe
# deb-src http://security.ubuntu.com/ubuntu focal-security universe
deb http://archive.ubuntu.com/ubuntu jammy-security multiverse
# deb-src http://security.ubuntu.com/ubuntu focal-security multiverse

# This system was installed using small removable media
# (e.g. netinst, live or single CD). The matching "deb cdrom"
# entries were disabled at the end of the installation process.
# For information about how to configure apt package sources,
# see the sources.list(5) manual.
deb http://security.ubuntu.com/ubuntu/ jammy-security universe restricted main multiverse

sudo apt update && sudo apt -f install && sudo apt full-upgrade displayed this:

Hit:1 https://cli.github.com/packages stable InRelease
Hit:2 http://repository.spotify.com stable InRelease                           
Hit:3 http://archive.ubuntu.com/ubuntu jammy InRelease                         
Hit:4 https://download.docker.com/linux/ubuntu jammy InRelease                 
Hit:5 http://archive.ubuntu.com/ubuntu jammy-security InRelease                
Hit:6 http://security.ubuntu.com/ubuntu jammy-security InRelease               
Hit:7 http://packages.microsoft.com/repos/code stable InRelease                
Hit:8 https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu jammy InRelease   
Hit:9 https://dl.google.com/linux/chrome/deb stable InRelease                  
Hit:10 https://packages.redis.io/deb jammy InRelease                           
Hit:11 https://ppa.launchpadcontent.net/obsproject/obs-studio/ubuntu jammy InRelease
Hit:12 https://ppa.launchpadcontent.net/pipewire-debian/pipewire-upstream/ubuntu jammy InRelease
Hit:13 https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/jammy pgadmin4 InRelease
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
All packages are up to date.
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

ls /etc/apt/preferences.d/ displayed this:

nosnap.pref

cat nosnap.pref displayed this:

# To prevent repository packages from triggering the installation of snap,
# this file forbids snapd from being installed by APT.

Package: snapd
Pin: release a=*
Pin-Priority: -10

Thank you in advance.

Raffa avatar
jp flag
Please [edit] your question to show the output of `cat /etc/apt/sources.list`
us flag
Run `sudo apt update` and try `sudo apt install snapd` again
Nedo avatar
gl flag
@ArchismanPanigrahi Did not work
user535733 avatar
cn flag
Please edit your question show us the complete output of `sudo apt update` and of `sudo apt upgrade`. "*Did not work*" is too vague to offer useful advice. We need to see the error messages you omitted that explain *why* it did not work.
Raffa avatar
jp flag
Please run `ls /etc/apt/preferences.d/` to see if there are files under that directory and if any are found, run `cat` on them and add their filenames and contents to your question.
user535733 avatar
cn flag
I do not see `jammy-updates` among your sources.
Nedo avatar
gl flag
@Raffa I've edited my question
Score:2
jp flag

/etc/apt/preferences.d/nosnap.pref appears to be an APT preferences control file that has instructions telling APT to not install the package snapd:

# To prevent repository packages from triggering the installation of snap,
# this file forbids snapd from being installed by APT.

Package: snapd
Pin: release a=*
Pin-Priority: -10

Hence the error message you see:

E: Package 'snapd' has no installation candidate

These APT preferences control files under /etc/apt/preferences.d/ need to follow a certain naming convention that requires the file extension(if one is used) to be in the form of .pref in order for APT to parse and process them.

Therefore, you can disable them by changing the file extension to e.g. .pref.disabled like so:

sudo mv /etc/apt/preferences.d/nosnap.pref /etc/apt/preferences.d/nosnap.pref.disabled

APT might print a notice that it has ignored a file in the directory /etc/apt/preferences.d/ because it has an invalid filename extension.

Of course moving that file outside the directory /etc/apt/preferences.d/ or deleting it are other alternatives that would work too minus the APT printed notice.

After dealing with that file, you should be able to install snapd after updating APT's cached repositories lists(although not a must after that action per-se but good practice nonetheless)

Nedo avatar
gl flag
Thank you very much
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.