charmcraft Pack is not Working
Metadata
Current evaluation
Resolved via user environment fix. The permission error stemmed from running charmcraft as root with root-owned files. Switching to a regular user, adding them to the lxd group, and correcting ownership allowed pack to succeed. No code changes required.
Suggested action: —
No scores available.
Issue body
Hello Team,
charmcraft pack command is not working. PFB error and all the required details
root@microk8s2:/home/vagrant/abc# charmcraft version
1.1.1
root@microk8s2:/home/vagrant/abc# whoami
root
root@microk8s2:/home/vagrant/abc# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.2 LTS
Release: 20.04
Codename: focal
root@microk8s2:/home/vagrant/abc# lxd --version
4.0.7
root@microk8s2:/home/vagrant/abc# charmcraft pack
Packing charm 'abc_ubuntu-20.04-amd64.charm'...
charmcraft internal error! PermissionError: [Errno 13] Permission denied: '/root/project/build' (full execution logs in /tmp/charmcraft.log)
Failed to build charm for bases index '0'. (full execution logs in '/root/snap/charmcraft/common/charmcraft-log-1bcbfndd')
root@microk8s2:/home/vagrant/abc# more /root/snap/charmcraft/common/charmcraft-log-1bcbfndd
2021-08-16 08:41:10,548 charmcraft.guard DEBUG Starting charmcraft version 1.1.1
mm 2021-08-16 08:41:47,994 charmcraft.commands.build DEBUG Building charm in '/root/project/build'
mm 2021-08-16 08:41:47,994 charmcraft ERROR charmcraft internal error! PermissionError: [Errno 13] Permission denied: '/roo
t/project/build' (full execution logs in /tmp/charmcraft.log)
mm 2021-08-16 08:41:47,997 charmcraft.guard ERROR
Traceback (most recent call last):
File "/snap/charmcraft/x4/lib/charmcraft/main.py", line 362, in main
dispatcher.run()
File "/snap/charmcraft/x4/lib/charmcraft/main.py", line 348, in run
self.command.run(self.parsed_args)
File "/snap/charmcraft/x4/lib/charmcraft/commands/pack.py", line 132, in run
self._pack_charm(parsed_args)
File "/snap/charmcraft/x4/lib/charmcraft/commands/pack.py", line 161, in _pack_charm
builder.run(parsed_args.bases_index)
File "/snap/charmcraft/x4/lib/charmcraft/commands/build.py", line 220, in run
charm_name = self.build_charm(bases_config)
File "/snap/charmcraft/x4/lib/charmcraft/commands/build.py", line 165, in build_charm
self.buildpath.mkdir()
File "/snap/charmcraft/x4/usr/lib/python3.8/pathlib.py", line 1288, in mkdir
self._accessor.mkdir(self, mode)
PermissionError: [Errno 13] Permission denied: '/root/project/build'
2021-08-16 08:41:48,696 craft_providers.lxd.lxc DEBUG Executing on host: lxc --project charmcraft config device show local:charmcraft-ab
c-777845-0-0-amd64
2021-08-16 08:41:48,884 craft_providers.lxd.lxc DEBUG Executing on host: lxc --project charmcraft config device remove local:charmcraft-
abc-777845-0-0-amd64 disk-/root/project
2021-08-16 08:41:49,229 craft_providers.lxd.lxc DEBUG Executing on host: lxc --project charmcraft stop local:charmcraft-abc-777845-0-0-a
md64
2021-08-16 08:41:51,615 charmcraft ERROR Failed to build charm for bases index '0'. (full execution logs in '/root/snap/cha
rmcraft/common/charmcraft-log-1bcbfndd')
Let me know if you need more from my end.
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| qwen3.6-35b-a3b-mtp-q6 | — | — | Resolved via user environment fix. The permission error stemmed from running charmcraft as root with root-owned files. Switching to a regular user, adding them to the lxd group, and correcting ownership allowed pack to succeed. No code changes required. | |
| qwen/qwen3.6-35b-a3b | — | — | Resolved by user. The permission error stemmed from running charmcraft pack as root. Maintainer advised using a regular user in the lxd group and correcting project ownership. User applied the fix and confirmed successful packaging. | |
| qwen/qwen3.6-35b-a3b | — | — | The charmcraft pack command failed due to running as root and missing LXD group permissions. The user resolved the issue by running without sudo, adding their user to the lxd group, and refreshing the session. The issue was closed as resolved. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Resolved by user. Running charmcraft pack as root caused a permission error. Maintainer advised removing sudo, adding the user to the lxd group, and fixing project ownership. The pack command succeeded after these changes, closing the issue. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Resolved via user configuration. The permission error occurred when running as root. Adding the user to the lxd group, correcting project ownership, and running without sudo allowed charmcraft pack to succeed. Closed. |
Update history
No update history recorded yet.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #685 charmcraft pack errors with LXDError - Name can only contain alphanumeric and hyphen characters | charmcraft | closed | Resolved as an upstream LXD bug. The error originated from overly strict device name validation in certain LXD revisions. Fixed in LXD 4.23 revision 22525; users should update LXD to restore charmcraft pack functionality. | |
| #660 `charmcraft pack` fails with error writing to lxd unix socket | charmcraft | closed | charmcraft pack failed due to an LXD socket I/O timeout. The author closed the issue as the error did not recur after a clean rebuild. No code changes were applied. | |
| #1931 Successfully pack charm with incorrect charm.py file permission | charmcraft | open | charmcraft pack succeeds even when src/charm.py lacks the execute bit, producing a charm that fails at deploy with 'Permission denied'. Requested a warning/error or auto-fix at pack time. No maintainer activity; an entrypoint linter now exists but only runs via charmcraft analyze, not pack. | |
| #501 charmcraft pack fails trying to include a non-existing charm/src/.tox/ | charmcraft | closed | charmcraft pack failed when copying non-existent build directories or files. Users worked around it with charmcraft clean. The issue was closed as fixed upstream in the underlying parts lifecycle code. | |
| #907 `charmcraft pack` does not handle updating a file's execution permissions without a `charmcraft clean` | charmcraft | open | charmcraft pack ignores local file permission changes (e.g., chmod +x on src/charm.py) until a full charmcraft clean, causing confusing lint errors. Maintainer reproduced and filed upstream craft-parts#311; still unfixed. | |
| #560 Charmcraft pack is giving error frequently | charmcraft | closed | Charmcraft pack failed due to an apt-get network error installing snapd in an LXD container. Maintainers linked it to a known networking issue. The reporter confirmed a workaround failed. Closed without a code fix, likely abandoned. | |
| #1104 charmcraft pack on Ubuntu 23.04 (Lunar) fails. | charmcraft | closed | Charmcraft pack failed on Ubuntu 23.04 due to unavailable build environments. PR #1130 addressed the issue but was blocked by an external cloud-images bug. The issue was closed pending upstream resolution. | |
| #2402 Odd error when packing | charmcraft | closed | A typo in charmcraft caused a chown command to fail with a permission string. The author identified it should be chmod. The issue was closed, confirming the bug was fixed in charmcraft to resolve the packing error. | |
| #511 `charmcraft pack` fails running `apt update` | charmcraft | closed | Closed as out of scope. The failure stemmed from an LXD container networking bug, not charmcraft. No code changes were implemented; users were directed to external LXD and Discourse discussions for troubleshooting. |