Snapcraft error: cannot create user data directory (permission denied)

Hi, I don’t know what changed but our approach to building snaps no longer works.

We use lxd (6.8) as build backend and after cleaning the build environment (snapcraft clean), the build (snapcraft pack) fails with:

cannot create user data directory: /root/snap/snapcraft/17616: Permission denied
Failed to execute pack in instance.

This is with snapcraft 8.14.5 - I reverted to the other available version (since maybe that’s what was used last time around), which is 8.14.4. With that, the error changes to something possibly more useful:

craft-providers error: failed to inject host's snap 'snapcraft' into target environment.
* Command that failed: 'lxc --project snapcraft exec local:snapcraft-<snap-name>-on-arm64-for-arm64-396407 -- env PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin CRAFT_MANAGED_MODE=1 DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true DEBIAN_PRIORITY=critical snap install /tmp/snapcraft.snap --classic'
* Command exit code: 1
* Command standard error output: b'error: cannot perform the following tasks:\n- Mount snap "snapcraft" (17287) (umount: /snap/snapcraft/17287: must be superuser to unmount.)\n- Run configure hook of "snapcraft" snap if present (run hook "configure": cannot create user data directory: /root/snap/snapcraft/17287: Permission denied)\n'

With this version there’s only the same error is in the build log, but there’s additionally a stacktrace with 8.14.5:

2026-05-27 07:12:48.684 Failed to execute pack in instance.
2026-05-27 07:12:48.692 Traceback (most recent call last):
2026-05-27 07:12:48.692   File "/snap/snapcraft/17616/lib/python3.12/site-packages/snapcraft/application.py", line 472, in main
2026-05-27 07:12:48.692     return app.run()
2026-05-27 07:12:48.692            ^^^^^^^^^
2026-05-27 07:12:48.692   File "/snap/snapcraft/17616/lib/python3.12/site-packages/craft_application/application.py", line 676, in run
2026-05-27 07:12:48.692     return_code = self._run_inner()
2026-05-27 07:12:48.693                   ^^^^^^^^^^^^^^^^^
2026-05-27 07:12:48.693   File "/snap/snapcraft/17616/lib/python3.12/site-packages/snapcraft/application.py", line 183, in _run_inner
2026-05-27 07:12:48.693     return_code = super()._run_inner()
2026-05-27 07:12:48.693                   ^^^^^^^^^^^^^^^^^^^^
2026-05-27 07:12:48.693   File "/snap/snapcraft/17616/lib/python3.12/site-packages/craft_application/application.py", line 619, in _run_inner
2026-05-27 07:12:48.693     dispatcher = self._get_dispatcher()
2026-05-27 07:12:48.693                  ^^^^^^^^^^^^^^^^^^^^^^
2026-05-27 07:12:48.693   File "/snap/snapcraft/17616/lib/python3.12/site-packages/snapcraft/application.py", line 410, in _get_dispatcher
2026-05-27 07:12:48.693     self._check_for_classic_fallback()
2026-05-27 07:12:48.693   File "/snap/snapcraft/17616/lib/python3.12/site-packages/snapcraft/application.py", line 322, in _check_for_classic_fallback
2026-05-27 07:12:48.693     raise errors.ClassicFallback()
2026-05-27 07:12:48.693 snapcraft.errors.ClassicFallback
2026-05-27 07:12:48.693
2026-05-27 07:12:48.693 During handling of the above exception, another exception occurred:
2026-05-27 07:12:48.693 Traceback (most recent call last):
2026-05-27 07:12:48.693   File "/snap/snapcraft/17616/lib/python3.12/site-packages/snapcraft/parts/lifecycle.py", line 534, in _run_in_provider
2026-05-27 07:12:48.693     instance.execute_run(cmd, check=True, cwd=output_dir)
2026-05-27 07:12:48.693   File "/snap/snapcraft/17616/lib/python3.12/site-packages/craft_providers/lxd/lxd_instance.py", line 272, in execute_run
2026-05-27 07:12:48.693     return self.lxc.exec(
2026-05-27 07:12:48.693            ^^^^^^^^^^^^^^
2026-05-27 07:12:48.693   File "/snap/snapcraft/17616/lib/python3.12/site-packages/craft_providers/lxd/lxc.py", line 528, in exec
2026-05-27 07:12:48.693     return runner(final_cmd, timeout=timeout, check=check, **kwargs)
2026-05-27 07:12:48.694            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2026-05-27 07:12:48.694   File "/snap/snapcraft/current/usr/lib/python3.12/subprocess.py", line 571, in run
2026-05-27 07:12:48.694     raise CalledProcessError(retcode, process.args,
2026-05-27 07:12:48.694 subprocess.CalledProcessError: Command '['lxc', '--project', 'snapcraft', 'exec', 'local:snapcraft-<snap-name>-on-arm64-for-arm64-396407', '--cwd', '/root/project', '--', 'env', 'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin', 'CRAFT_MANAGED_MODE=1', 'DEBIAN_FRONTEND=noninteractive', 'DEBCONF_NONINTERACTIVE_SEEN=true', 'DEBIAN_PRIORITY=critical', 'snapcraft', 'pack', '--verbosity=brief', '--build-for', 'arm64']' returned non-zero exit status 1.

Running with --debug doesn’t drop me in the container as it’s not started in the first place.

Initially there was still a lx container from a previous build, but I removed that with the same result. Reboot didn’t help either, and I can still build other snaps so long as I don’t clear the environment. Any ideas what I might need to change?

In case anyone else encounters this, I “fixed” it by downgrading lxd to 5.0.

I don’t know what the exact issue is or why it stopped working (I’m certain it has also worked with 6.8), though.