`charmcraft` lxc container starts failing with `FileNotFoundError` during iterative design
Metadata
Current evaluation
Closed without a fix. Maintainer could not reproduce the LXC container corruption causing FileNotFoundError during charmcraft pack on newer versions. Reopen if reproducible on Charmcraft 2.7 or 3.
Suggested action: —
No scores available.
Issue body
Intermittently, we've found that our lxc containers used by `charmcraft pack` will get corrupted in some way, resulting in being unable to `charmcraft pack` the charm until we do a `charmcraft clean`. I don't know if it is always the same error, but one case of this is documented below.
This most recently happened when iterating on [this PR](https://github.com/canonical/minio-operator/pull/50). In the few days between initially pushing the PR (when local CI passed) and coming back to make edits from the reviews, the `charmcraft pack` process stopped working. The failure stated:
```
2022-03-31 10:06:37.119 :: 2022-03-31 14:06:27.987 updated files: {'.git/FETCH_HEAD', '.git/HEAD', '.git/config', '.git/index', 'tox.ini', 'test-requirements.txt', '.git/logs/HEAD', 'tests/unit/test_charm.py', '.git/COMMIT_EDITMSG', 'tests/unit/__pycache__/test_charm.cpython-39-pytest-7.1.1.pyc'}
2022-03-31 10:06:37.119 :: 2022-03-31 14:06:27.987 updated directories: {'.git/refs/heads', '.kube/cache/discovery/127.0.0.1_16443', '.git/objects', 'venv', 'src', '.kube/cache/http', '.pytest_cache/v/cache', 'tests/unit/.pytest_cache', '.tox', '.git/info', '.idea', '.git/refs/remotes/origin', 'tests/integration', "'./.tox", '.git/logs/refs', '.git/hooks'}
2022-03-31 10:06:37.119 :: 2022-03-31 14:06:36.614 Parts processing error: Failed to copy '/root/parts/charm/src/tests/unit/__pycache__/test_charm.cpython-39-pytest-7.1.1.pyc': no such file or directory.
2022-03-31 10:06:37.119 :: 2022-03-31 14:06:36.619 Traceback (most recent call last):
2022-03-31 10:06:37.119 :: 2022-03-31 14:06:36.619 File "/snap/charmcraft/x9/lib/craft_parts/utils/file_utils.py", line 146, in copy
2022-03-31 10:06:37.120 :: 2022-03-31 14:06:36.619 shutil.copy2(source, destination, follow_symlinks=follow_symlinks)
2022-03-31 10:06:37.120 :: 2022-03-31 14:06:36.619 File "/snap/charmcraft/x9/usr/lib/python3.8/shutil.py", line 435, in copy2
2022-03-31 10:06:37.120 :: 2022-03-31 14:06:36.619 copyfile(src, dst, follow_symlinks=follow_symlinks)
2022-03-31 10:06:37.120 :: 2022-03-31 14:06:36.619 File "/snap/charmcraft/x9/usr/lib/python3.8/shutil.py", line 264, in copyfile
2022-03-31 10:06:37.120 :: 2022-03-31 14:06:36.619 with open(src, 'rb') as fsrc, open(dst, 'wb') as fdst:
2022-03-31 10:06:37.120 :: 2022-03-31 14:06:36.619 FileNotFoundError: [Errno 2] No such file or directory: '/root/parts/charm/build/tests/unit/__pycache__/test_charm.cpython-39-pytest-7.1.1.pyc'
2022-03-31 10:06:37.120 :: 2022-03-31 14:06:36.619
2022-03-31 10:06:37.120 :: 2022-03-31 14:06:36.619 The above exception was the direct cause of the following exception:
2022-03-31 10:06:37.120 :: 2022-03-31 14:06:36.619 Traceback (most recent call last):
2022-03-31 10:06:37.120 :: 2022-03-31 14:06:36.619 File "/snap/charmcraft/x9/lib/charmcraft/parts.py", line 320, in run
2022-03-31 10:06:37.120 :: 2022-03-31 14:06:36.619 aex.execute(actions)
2022-03-31 10:06:37.120 :: 2022-03-31 14:06:36.619 File "/snap/charmcraft/x9/lib/craft_parts/executor/executor.py", line 269, in execute
2022-03-31 10:06:37.120 :: 2022-03-31 14:06:36.619 self._executor.execute(actions)
2022-03-31 10:06:37.120 :: 2022-03-31 14:06:36.619 File "/snap/charmcraft/x9/lib/craft_parts/executor/executor.py", line 118, in execute
2022-03-31 10:06:37.120 :: 2022-03-31 14:06:36.619 self._run_action(act)
2022-03-31 10:06:37.120 :: 2022-03-31 14:06:36.619 File "/snap/charmcraft/x9/lib/craft_parts/executor/executor.py", line 168, in _run_action
2022-03-31 10:06:37.120 :: 2022-03-31 14:06:36.619 handler.run_action(action)
2022-03-31 10:06:37.120 :: 2022-03-31 14:06:36.619 File "/snap/charmcraft/x9/lib/craft_parts/executor/part_handler.py", line 95, in run_action
2022-03-31 10:06:37.120 :: 2022-03-31 14:06:36.619 self._update_action(action, step_info=step_info)
2022-03-31 10:06:37.120 :: 2022-03-31 14:06:36.619 File "/snap/charmcraft/x9/lib/craft_parts/executor/part_handler.py", line 418, in _update_action
2022-03-31 10:06:37.120 :: 2022-03-31 14:06:36.619 handler(step_info)
2022-03-31 10:06:37.120 :: 2022-03-31 14:06:36.619 File "/snap/charmcraft/x9/lib/craft_parts/executor/part_handler.py", line 491, in _update_build
2022-03-31 10:06:37.120 :: 2022-03-31 14:06:36.619 source.update()
2022-03-31 10:06:37.120 :: 2022-03-31 14:06:36.619 File "/snap/charmcraft/x9/lib/craft_parts/sources/local_source.py", line 147, in update
2022-03-31 10:06:37.120 :: 2022-03-31 14:06:36.619 self.copy_function(
2022-03-31 10:06:37.120 :: 2022-03-31 14:06:36.619 File "/snap/charmcraft/x9/lib/craft_parts/utils/file_utils.py", line 148, in copy
2022-03-31 10:06:37.120 :: 2022-03-31 14:06:36.619 raise errors.CopyFileNotFound(source) from err
2022-03-31 10:06:37.120 :: 2022-03-31 14:06:36.619 craft_parts.errors.CopyFileNotFound: Failed to copy '/root/parts/charm/src/tests/unit/__pycache__/test_charm.cpython-39-pytest-7.1.1.pyc': no such file or directory.
```
I looked in the container and noted that `/root/parts/charm/src/tests/unit/__pycache__/` **did not** exist, so likely the error is because it couldn't copy the `.pyc` file because the full path wasn't valid.
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| qwen3.6-35b-a3b-mtp-q6 | — | — | Closed without a fix. Maintainer could not reproduce the LXC container corruption causing FileNotFoundError during charmcraft pack on newer versions. Reopen if reproducible on Charmcraft 2.7 or 3. | |
| qwen/qwen3.6-35b-a3b | — | — | Closed as unreproducible. The maintainer could not replicate the LXC container corruption causing FileNotFoundError on newer charmcraft versions. Users should reopen if the issue persists on v2.7 or v3. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Closed as unreproducible. Intermittent FileNotFoundError during charmcraft pack LXC container builds could not be replicated on newer Charmcraft versions 2.7 and 3. Maintainers advised reopening if a valid reproducer is available. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Intermittent charmcraft pack failures in LXC containers due to missing .pyc files were closed without a fix. Maintainers could not reproduce the error on newer versions and requested a reproducer if it persists on Charmcraft 2.7 or 3. |
Update history
No update history recorded yet.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #1930 `charmcraft pack -o` fails: `FileNotFoundError` | charmcraft | closed | A FileNotFoundError with charmcraft pack -o was abandoned and closed without resolution. No fix was implemented, and a recent comment confirms the bug persists. | |
| #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. | |
| #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. | |
| #647 `charmcraft build` sometimes fails on `apt install` inside the lxd container | charmcraft | closed | Closed as a duplicate of issue #567. The report details intermittent apt-get lock failures during charmcraft build inside LXD containers, suspected to be caused by unattended-upgrades. |