charmcraft Pack is not Working
Metadata
Current evaluation
Packaging succeeded after using the project owner with LXD permissions and cleaning stale state; the reporter confirmed the .charm file was created.
Resolution: closed not a bug
Reason: Maintainer @cjp256 diagnosed an environment and ownership problem, advising a non-root run, lxd group membership, and `charmcraft clean`. The reporter then confirmed that `charmcraft pack` successfully created abcd_ubuntu-20.04-amd64.charm.
Evaluated by: mr-cal-bot
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 |
|---|---|---|---|---|
| stealth/space-bunny-alpha | — | closed not a bug | Packaging succeeded after using the project owner with LXD permissions and cleaning stale state; the reporter confirmed the .charm file was created. | |
| stealth/space-bunny-alpha | — | closed not a bug | Resolved as an environment setup issue: run pack as the project owner, grant that user LXD access, and clean build state; the reporter confirmed the charm was created. | |
| stealth/space-bunny-alpha | — | closed not a bug | Resolved as an environment configuration problem: run Charmcraft as the project owner, add the user to the lxd group, and reset build state. The reporter confirmed packing then succeeded. | |
| stealth/space-bunny-alpha | — | closed not a bug | Charmcraft 1.1.1 failed to pack a root-owned project. Adding the user to the lxd group, running charmcraft clean, and packing as that user succeeded. | |
| 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. |
Update history
No update history recorded yet.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #660 `charmcraft pack` fails with error writing to lxd unix socket | charmcraft | closed | A transient LXD socket timeout stopped packing; `charmcraft clean` restored operation, the error did not recur, and the reporter closed the report without a code fix. | |
| #815 charmcraft pack fails - connection timed out could not connect | charmcraft | closed | User-reported charmcraft pack failure was a local host/network problem (archive.ubuntu.com/security.ubuntu.com unreachable during apt cache update in the LXD build container). Author rebooted their machine and packing worked again, then self-closed the issue. | |
| #501 charmcraft pack fails trying to include a non-existing charm/src/.tox/ | charmcraft | closed | The missing-file packing failure was fixed upstream in craft-parts; maintainer lengau closed charmcraft#501 on 2024-02-22 as resolved. | |
| #685 charmcraft pack errors with LXDError - Name can only contain alphanumeric and hyphen characters | charmcraft | closed | Packing failures came from an upstream LXD 4.23 device-name validation regression, fixed in revision 22525 or later; no Charmcraft code change was needed. | |
| #1594 Running `charmcraft pack` fails and returns `Instance setup failed. Check LXD logs for more details` | charmcraft | closed | Closed as an environment conflict, not a Charmcraft defect: Docker had changed networking in a way that interfered with LXD, and the reporter confirmed that uninstalling Docker and restarting fixed it. |