Multipass: fails to copy symlinks

I am building gadget snap on Ubuntu 20.04 machine with Ubuntu 22.04 LTS multipass image The last successful build was at the end of July.

Current installed multipass version 1.14.0 2024-08-19 (13113)

build fails in pull stage copying source from local folder to parts (cp command in override-pull section in snapcraft.yaml)

cp: cannot read symbolic link '…: Permission denied

running cp command manually inside multipass shell giving the same error tried with different parameters cp -d, cp -a

The shared folder mounted with default settings: multipass mount ./ ubuntu-jammy:/mnt

Since the name of the VM is ubuntu-jammy, am I correct in assuming this is a VM you created? As in, this is not a Snapcraft-managed VM?

running cp command manually inside multipass shell giving the same error

Does the directory you mounted have symlinks to paths outside the mounted directory? Or are their filepaths with insufficient permissions? More details on the symlinks and the files they link to would be useful.

Yes “ubuntu-jammy” is the name of an instance i have created: multipass launch jammy --name ubuntu-jammy

The source consists from many different packages which were put together for a device BSP release some time ago. The source is from different parties and we do not own some of the sources. I am aware some links point to a non-existing locations and build of that particular components will take care of them.
The expectation is that at least cp command with -d parameter is supposed to copy them as is. Outside of the instance “cp -r” also works. Permissions seems to be ok:

lrwxrwxrwx 1 ubuntu ubuntu   12 Apr 14  2023 "symlink-name-here"

The image version: “path”: “/var/snap/multipass/common/cache/multipassd/vault/images/jammy-20240821/ubuntu-22.04-server-cloudimg-amd64.img”, “release_date”: “20240821”

How can I try previous image version?

You can see what previous images are available from Ubuntu Cloud Images.

As of today, the furthest back you can go is 2024-08-02 with multipass launch https://cloud-images.ubuntu.com/jammy/20240802/jammy-server-cloudimg-amd64-disk-kvm.img for amd64

The same error.

Easy steps to reproduce the problem:

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.6 LTS
Release: 20.04
Codename: focal

— On a host machine:

$ cd ~/tmp
$ mkdir test
$ mkdir dest
$ cd test
$ touch file.txt
$ ln -s ./file.txt ./mysymlink
$ rm file.txt \

$ multipass launch jammy --name ubuntu-jammy
$ multipass mount ./ ubuntu-jammy:/mnt
$ multipass shell ubuntu-jammy \

— Inside ubuntu-jammy instance:

$ cp test/mysymlink dest/
cp: cannot stat ‘test/mysymlink’: Permission denied

$ cp -r test/mysymlink dest/
cp: cannot read symbolic link ‘test/mysymlink’: Permission denied

$ cp -d test/mysymlink dest/
cp: cannot read symbolic link ‘test/mysymlink’: Permission denied

$ cp -a test/mysymlink dest/ cp: cannot read symbolic link ‘test/mysymlink’: Permission denied

Outside of VM instance cp with r, d or a parameters successfully copies the link.

VM, created from image 22.04 jammy 20240821 Ubuntu 22.04 LTS
Current installed multipass version 1.14.0 2024-08-19 (13113)

I’m not sure if that behavior for dangling symlinks is expected or not for Multipass. I would recommend bringing that reproducer to the Multipass forums or Github issues page.

It looks like this is a recent regression in Multipass: Multipass mounted directory permission issues (tox and virtualenv) · Issue #3620 · canonical/multipass · GitHub

Thanks for pointing to the bug. I was using --native mount for shared folder, it solved the issue for my build for now. Also I have noticed multipass was updated yesterday 2024-09-04 to revision 13186. it may have a fix to the isue. But I did not tested it.