← Back to issue list

Charmcraft cannot build or pack from tmp dirs created with tempfile.mkdtemp

View original Github issue

Metadata

Project
charmcraft
Number
#380
Type
issue
State
closed
Author
mmanciop
Labels
—
Created
Updated
Closed

Current evaluation

Packing failed from tempfile.mkdtemp dirs due to the charmcraft snap's strict confinement (private /tmp mount ns). Fixed by moving the snap to classic confinement in PR #288 (commit d49e85e3), shipped in Charmcraft 1.0.0.

Resolution: closed resolved

Reason: The bug was caused by the snap's strict confinement; PR #288 (commit d49e85e3, 'snap: strict -> classic confinement for Charmcraft snap', merged in 0d76670a) fixed it. Maintainer sergiusens closed the issue on 2021-09-06 noting 'Charmcraft is now classic so tempfile is no longer a mount namespace in the context of the snap since 1.0.0'.

Evaluated by: mr-cal-bot

No scores available.

Issue body

When creating a charm from a directory created via `tempfile.mkdtemp`, `charmcraft` fails with: ```sh $ charmcraft pack -p /tmp/appcraft-cnb-charmhi8ovz95 Charm directory was not found: '/tmp/appcraft-cnb-charmhi8ovz95' (full execution logs in <snip>/snap/charmcraft/common/charmcraft-log-b4sdcl06) ``` Needless to say, the directory and all the expected files are in fact there, confirmed via a `find /tmp/appcraft-cnb-charmhi8ovz95`: ```sh $ find /tmp/appcraft-cnb-charmhi8ovz95 /tmp/appcraft-cnb-charm-p9h_yd6x /tmp/appcraft-cnb-charm-p9h_yd6x/NOTICE /tmp/appcraft-cnb-charm-p9h_yd6x/metadata.yaml /tmp/appcraft-cnb-charm-p9h_yd6x/src /tmp/appcraft-cnb-charm-p9h_yd6x/src/charm.py /tmp/appcraft-cnb-charm-p9h_yd6x/src/config.json /tmp/appcraft-cnb-charm-p9h_yd6x/LICENSE /tmp/appcraft-cnb-charm-p9h_yd6x/actions.yaml /tmp/appcraft-cnb-charm-p9h_yd6x/requirements.txt ``` When making a `mv /tmp/appcraft-cnb-charmhi8ovz95 ~/appcraft-cnb-charmhi8ovz95`, followed by a `charmcraft pack -p ~/appcraft-cnb-charmhi8ovz95`, it all works as expected.

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha — closed resolved Packing failed from tempfile.mkdtemp dirs due to the charmcraft snap's strict confinement (private /tmp mount ns). Fixed by moving the snap to classic confinement in PR #288 (commit d49e85e3), shipped in Charmcraft 1.0.0.
stealth/space-bunny-alpha — closed resolved Resolved in Charmcraft 1.0.0 by switching its snap from strict to classic confinement, fixing /tmp path resolution and pack failures.
qwen3.6-35b-a3b-mtp-q6 — — Fixed. Charmcraft failed to pack from tempfile.mkdtemp directories due to snap confinement mount namespace restrictions. The issue was resolved when Charmcraft transitioned to classic confinement in v1.0.0, eliminating the path resolution problem.
qwen/qwen3.6-35b-a3b — — Resolved by switching Charmcraft to classic confinement in v1.0.0, eliminating snap mount namespace restrictions that broke temp directory access.
qwen/qwen3.6-35b-a3b — — Fixed by migrating Charmcraft to classic confinement in v1.0.0. Snap confinement isolated tempfile dirs via mount namespaces, causing path failures. Classic mode removes this restriction.
qwen3.6-35b-a3b-mtp-q6 — — Fixed in v1.0.0 by migrating Charmcraft to classic snap confinement, resolving the mount namespace issue that blocked packing from tempfile.mkdtemp directories.

Update history

No update history recorded yet.

Related work

  • Likely Fixed By: canonical/charmcraft#288 (confidence 92%)

    PR 'snap-classic' by cjp256; commit d49e85e3 changed the charmcraft snap from strict to classic confinement, removing the private /tmp mount namespace that hid mkdtemp dirs.

  • Caused By: canonical/charmcraft#288 (confidence 70%)

    Reverse of the same reference: strict confinement in the snap packaging was the root cause of the invisible /tmp directory.

Related issues

Issue Project State Summary Similarity
#184 Charmcraft crash when snap is used in /tmp directory charmcraft closed Fixed the /tmp PermissionError by switching the Charmcraft snap from strict to classic confinement in merged PR #288 (d49e85e3, 0d76670a).
80%
#388 Charmcraft pack cannot run in a CI? charmcraft closed charmcraft's strictly-confined snap blocked CI builds (pip deps install failing). Fixed by switching the snap to classic confinement (PR #288, commit d49e85e3); reporter confirmed the edge classic snap resolved their CI.
71%