fatal: detected dubious ownership in repository at '/root/project' when ran with --use-lxd

Bug #1990298 reported by Michał Sawicz
20
This bug affects 4 people
Affects Status Importance Assigned to Milestone
Snapcraft
Confirmed
Undecided
Unassigned

Bug Description

Snapcraft 7.1.3 on Kinetic

```
mkdir foo
cd foo
snapcraft init
sed -i 's/version:.*/version: git/' snap/snapcraft.yaml
git init .
snapcraft --use-lxd # ... LP#1990297
snapcraft --use-lxd
# ...
Determining the version from the project repo (version: git).
fatal: detected dubious ownership in repository at '/root/project'
To add an exception for this directory, call:

        git config --global --add safe.directory /root/project
Run the same command again with --debug to shell into the environment if you wish to introspect this failure.
```

Tags: craft-1574
Revision history for this message
Callahan Kovacs (mr-cal) wrote (last edit ):

I'm able to reproduce using core18, 20, and 22 with a few extra steps:

```
su <user1>
mkdir foo
cd foo
snapcraft init
sed -i 's/version:.*/version: git/' snap/snapcraft.yaml
git init .
git add -A
git commit -m "initial commit"
snapcraft --use-lxd

su <user2>
# cd to previous directory
snapcraft --use-lxd
```

The first run of snapcraft creates a container `snapcraft-my-snap-name` with a configuration `raw.idmap=both <uid of user1> 0`.
The second execution of snapcraft reuses the same LXD container, but the `raw.idmap` configuration is never updated with the second user's ID.

This causes an issue with UID/GID translation for the LXD container. When the project directory is mounted in the container, it is owned by `nobody:nogroup`.

Normally, this is not a problem and the snap will build. However, when snapcraft uses `version: git`, git will raise an error about the ownership of the project directory.

Changed in snapcraft:
status: New → Confirmed
Callahan Kovacs (mr-cal)
tags: added: craft-1574
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.