Cannot change mount namespace

Hi,

After creating my own snap, whenever I want to install my snap with the command “sudo snap install mysnap --devmode”, I encounter the following error:

- Run install hook of "myapplication" snap if present (run hook "install": 
-----
update.go:85: cannot change mount namespace according to change mount 
(/var/lib/snapd/hostfs/boot /boot none bind,ro 0 0): permission denied
cannot update snap namespace: cannot open directory "/bin": not a directory
 snap-update-ns failed with code 1
  -----)

I read the related threads to this error, but I couldn’t find something to help me for solving the problem.

Hi, would please share your snapcraft.yaml using triple quotes (to preserve indentation).

Hi again,

I think finally I found the solution to this thread. Because I used the following defined layout with core20, I encountered the mentioned error. Although when I use it with core18, I receive no error :

layout:
        /bin/mysh:
                  symlink: $SNAP/bin/bash

Instead of using the above layout, I have to define the below layout:

   layout:
        /usr/local/bin/mysh:
                  symlink: $SNAP/bin/bash

I will appreciate it if someone explains this matter why we cannot use the first way of definition of layout with core20, while according to this link, we should have no problem.