Warnings upon running `snapcraft` for the first time

Following the doc for creating snapcraft.yaml, after doing snapcraft.init (and installing mulitipass), the snapcraft command shows the following warnings:

    The 'snap' directory is meant specifically for snapcraft, but it contains the following non-snapcraft-related paths, which is unsupported and will cause unexpected behavior:
    - multipass
    - multipass/2259
    - multipass/2259/.config
    - multipass/2259/.config/autostart
    - multipass/2259/config
    - multipass/2259/config/autostart
    - multipass/2259/config/autostart/multipass.gui.autostart.desktop
    - multipass/2259/data
    - multipass/2259/data/multipass
    - multipass/2259/data/multipass/client-certificate
    - multipass/2259/data/multipass/client-certificate/multipass_cert.pem
    - multipass/2259/data/multipass/client-certificate/multipass_cert_key.pem
    - multipass/common
    - multipass/current
    - snapcraft
    - snapcraft/5143
    - snapcraft/common
    - snapcraft/current

    If you must store these files within the 'snap' directory, move them to 'snap/local', which is ignored by snapcraft.

    snapd is not logged in, snap install commands will use sudo

~/snap/snapcraft was created by snapcraft init (before I installed multipass), and ~/snap/multipass wasn’t there until I ran snapcraft (after installing multipass). So, it would seem that snapcraft is warning about the existence of files that it created.

Secondly, why am I being warned that “snapd is not logged in” and what should I do about it?

It sounds like you’re running snapcraft directly from your home directory. This is a bad idea, since you generally don’t want everything in your home directory to be considered part of the project.

Instead, try creating the project in a subdirectory of your home directory.

3 Likes

Thanks, @jamesh.

So I removed ~/snap and started afresh. Created ~/snap-project and did…

$ cd ~/snap-project
$ snapcraft init

This created ~/snap, ~/snap/snapcraft and ~/snap-project/snap/snapcraft.yaml. Then, in ~/snap-project, I ran snapcraft which apparently did what it was supposed to do but reported that it couldn’t find snap/snapcraft.yaml which is very much there – this happens with permissions for the file set to 777 so that’s not the cause.

$ cd ~/snap-project
$ snapcraft
Launching a VM.
snap "snapd" has no updates available                                           
Could not find snap/snapcraft.yaml. Are you sure you are in the right directory?
To start a new project, use `snapcraft init`
Run the same command again with --debug to shell into the environment if you wish to introspect this failure.

These are the contents of the relevant directories:

$ ls -a ~/snap
./  ../  multipass/  snapcraft/

$ ls -aR ~/snap-project
/home/myname/snap-project:
./  ../  snap/
                                                                                                              
/home/myname/snap-project/snap:                                                                               
./  ../  snapcraft.yaml 

snapcraft --debug puts me in a shell with snapcraft-my-snap-name # as the prompt. The name attribute in ~/snap-project/snap/snapcraft.yaml is “my-app-name” so it seems to have read from the file that it “could not find.” What am I missing?

Try running snapcraft clean to remove any remnant virtual machines before restarting the build.

Snapcraft will have created a virtual machine when you ran it from your home directory with a different virtual filesystem layout for the snapcraft.yaml there. You therefore need to remove this virtual machine so that snapcraft can create a new one in it’s place with the correct filesystem arrangement.

3 Likes