SNapcraft cannot open snap while installing snap

I am extremely new to IOT and have recently got myself a raspberry pi. I got Ubuntu installed on it and created a couple of snaps after connecting to ubuntu-core. The snap which was created is a armhf.snap file. When I run the snapcraft command, it gets built fine with no errors. But when I try to install the snap on my local environment, It gives me an error saying “snap requires classic confinement which is only available on classic systems”. I tried using sudo install snap --dangerous snap_name.snap --classic and I still get the error. When I just run sudo install snap snap_name, I get an error saying “cannot open snap”. Can anybody help me out?

The steps i followed are :

$ sudo snap install classic --edge --devmode
$ sudo classic
(classic)user@localhost:~$ sudo apt update
$ sudo apt install snapcraft build-essential git

$mkdir ancii
$cd ancii
$snapcraft init
*after adding code*
$snapcraft (No error)
$sudo install --dangerous ancii_armhf.snap" 

which gives me the error cannot open snap
Thanks.

Ok, things can get confusing here fast.

You have two “classic” things going on. You’ve installed the classic snap which enables you to apt install things and build software, as a snap. Then outside the classic environment you can install the snap, so you need to exit from the classic environment to install it.

However, if the snap you’re making is a “classic confined” snap (i.e. it contains confinement: classic then you cannot install that on the all-snap Ubuntu Core system (i.e. outside the classic snap) because core doesn’t support classic snaps.

If you rebuild it with confinement: devmode then you might be able to install it.

So when I install the snap without exiting the classic mode, I get the error “cannot open snap”.
I tried exiting from the classic mode with ctrl+d and when I tried to install it(with sudo install name.snap) here, I get the error "insall:missing destination file operand after “snapname.snap” I made sure I am in the right directory. I also tried $sudo install name.snap --dangerous and nothing happens.

It’s sudo snap install foo.snap - not sudo install foo.snap. You missed the snap command, and did install command under sudo, which is another command entirely.

Tried this after exiting the classic mode, still giving me the error “requires classic confinement”.

It will if your snapcraft.yaml has confinement: classic. You would need to rebuild it with confinement: devmode or confinement: strict. Might be easier if you paste the entire snapcraft.yaml.

This is what my snapcraft.yaml looks like right now
name: asciinema
version: ‘latest’
summary: One-line elevator pitch for asciinema
description: |
You can write a longer
multi-line paragraph in here.

grade: stable
confinement: classic

apps:
asciinema:
command: asciinema

parts:
asciinema:
source: https://github.com/asciinema/asciinema.git
plugin: python
python-version: ‘python3’

I changed the confinement to devmode and rebuilt it and tried installing in my local environment and got the error "snap requires devmode or confinement override.

You need --devmode when installing devmode snaps. So snap install foo.snap --devmode

Worked. Thank you so much. Sorry for the trouble!

1 Like