← Back to issue list

charmcraft errors out when mixing -p and -o flags

View original Github issue

Metadata

Project
charmcraft
Number
#2361
Type
issue
State
closed
Author
PietroPasotti
Labels
Created
Updated
Closed

Current evaluation

Resolved in PR #2600. charmcraft pack no longer fails with a FileNotFoundError when combining -p and -o flags. Regression tests were added in PR #2735.

Suggested action:

No scores available.

Issue body

### Bug Description in [this repo](https://github.com/canonical/tempo-operators) we have two charms, one under ./worker, one under ./coordinator I want to pack them in their respective subdirectories, without `cd`'ing, and the output charms to be in the respective subdirectories. however `charmcraft pack -p ./worker -o ./worker` fails with an error. ### To Reproduce - `git clone https://github.com/canonical/tempo-operators; cd tempo-operators` - `charmcraft pack -p ./worker -o ./worker` ### Environment installed: 3.5.2 (7023) juju info v0.1 ``` ┌──────────────┬───────────────────────────────────┐ │ jhack │ 0.4.4.0.20.26 │ │ python │ 3.10.12 (/bin/python3) │ │ juju-* snaps │ juju │ 3.6.7 - 31266 (3/stable) │ │ microk8s │ MicroK8s v1.31.7 revision 7968 │ │ lxd │ 6.4 │ │ multipass │ 1.15.1 │ │ multipassd │ 1.15.1 │ │ os │ Ubuntu 22.04.5 LTS │ │ kernel │ Linux 6.8.0-60-generic x86_64 │ └──────────────┴───────────────────────────────────┘ ``` ### charmcraft.yaml ```yaml likely irrelevant, but see: https://github.com/canonical/tempo-operators/blob/main/worker/charmcraft.yaml ``` ### Relevant log output ```shell 336 │ 2025-07-03 12:58:56.003 :: 2025-07-03 12:58:54.246 Packing charm tempo-coordinator-k8s_ubuntu@24.04-amd64.charm 337 │ 2025-07-03 12:58:56.003 :: 2025-07-03 12:58:55.631 Packed tempo-coordinator-k8s_ubuntu@24.04-amd64.charm 338 │ 2025-07-03 12:58:56.004 Executing on host: lxc --project charmcraft config device show local:charmcraft-tempo-coordinator-k8s-ubuntu--aa2fd111d0b32a60df53 339 │ 2025-07-03 12:58:56.093 Executing on host: lxc --project charmcraft config device remove local:charmcraft-tempo-coordinator-k8s-ubuntu--aa2fd111d0b32a60df53 disk-/root/.cache/pip 340 │ 2025-07-03 12:58:56.206 Executing on host: lxc --project charmcraft config device remove local:charmcraft-tempo-coordinator-k8s-ubuntu--aa2fd111d0b32a60df53 disk-/root/project 341 │ 2025-07-03 12:58:56.343 Executing on host: lxc --project charmcraft stop local:charmcraft-tempo-coordinator-k8s-ubuntu--aa2fd111d0b32a60df53 342 │ 2025-07-03 12:59:00.766 Executing on host: lxc --project charmcraft list local: --format=yaml 343 │ 2025-07-03 12:59:01.257 Executing on host: lxc --project charmcraft list local: --format=yaml 344 │ 2025-07-03 12:59:01.647 charmcraft internal error: FileNotFoundError(2, 'No such file or directory') 345 │ 2025-07-03 12:59:01.650 Traceback (most recent call last): 346 │ 2025-07-03 12:59:01.650 File "/snap/charmcraft/7023/usr/lib/python3.10/shutil.py", line 816, in move 347 │ 2025-07-03 12:59:01.650 os.rename(src, real_dst) 348 │ 2025-07-03 12:59:01.650 FileNotFoundError: [Errno 2] No such file or directory: '/home/pietro/canonical/tempo-operators/coordinator/tempo-coordinator-k8s_ubuntu@24.04-amd64.charm' -> '/home/pietro/canonical/tempo-operators/coordinator/tempo-coordinator-k8s_ubuntu@24.04-amd64.charm' 349 │ 2025-07-03 12:59:01.650 350 │ 2025-07-03 12:59:01.650 During handling of the above exception, another exception occurred: 351 │ 2025-07-03 12:59:01.650 Traceback (most recent call last): 352 │ 2025-07-03 12:59:01.650 File "/snap/charmcraft/7023/lib/python3.10/site-packages/craft_application/application.py", line 691, in run 353 │ 2025-07-03 12:59:01.650 return_code = self._run_inner() 354 │ 2025-07-03 12:59:01.650 File "/snap/charmcraft/7023/lib/python3.10/site-packages/craft_application/application.py", line 674, in _run_inner 355 │ 2025-07-03 12:59:01.650 self.run_managed(platform, build_for) 356 │ 2025-07-03 12:59:01.650 File "/snap/charmcraft/7023/lib/python3.10/site-packages/charmcraft/application/main.py", line 173, in run_managed 357 │ 2025-07-03 12:59:01.650 shutil.move( 358 │ 2025-07-03 12:59:01.650 File "/snap/charmcraft/7023/usr/lib/python3.10/shutil.py", line 836, in move 359 │ 2025-07-03 12:59:01.650 copy_function(src, real_dst) 360 │ 2025-07-03 12:59:01.650 File "/snap/charmcraft/7023/usr/lib/python3.10/shutil.py", line 434, in copy2 361 │ 2025-07-03 12:59:01.650 copyfile(src, dst, follow_symlinks=follow_symlinks) 362 │ 2025-07-03 12:59:01.650 File "/snap/charmcraft/7023/usr/lib/python3.10/shutil.py", line 254, in copyfile 363 │ 2025-07-03 12:59:01.650 with open(src, 'rb') as fsrc: 364 │ 2025-07-03 12:59:01.650 FileNotFoundError: [Errno 2] No such file or directory: '/home/pietro/canonical/tempo-operators/coordinator/tempo-coordinator-k8s_ubuntu@24.04-amd64.charm' 365 │ 2025-07-03 12:59:01.650 Full execution log: '/home/pietro/.local/state/charmcraft/log/charmcraft-20250703-125829.050512.log' ```

Evaluation history

Date Model Scores Action Summary
qwen3.6-35b-a3b-mtp-q6 Resolved in PR #2600. charmcraft pack no longer fails with a FileNotFoundError when combining -p and -o flags. Regression tests were added in PR #2735.
qwen/qwen3.8-27b
Impact: 50
Quick Win: 35.0
Staleness: 85
Complexity: 30
Confidence: 90
Support Request: 10
close stale charmcraft pack -p <dir> -o <same dir> crashes with FileNotFoundError in shutil.move when output dir equals project dir. Fixed by PR #2600 (commit 5e634d96) which skips the move when dirs match; issue is stale and resolved.
qwen/qwen3.6-35b-a3b
Staleness: 95
Complexity: 40
Confidence: 85
Support Request: 5
needs triage Charmcraft crashes with a FileNotFoundError when combining -p and -o flags. Report includes reproduction steps and traceback but remains unlabeled with zero maintainer engagement for over a year.
qwen3.6-35b-a3b-mtp-q6
Staleness: 85
Complexity: 30
Confidence: 80
Support Request: 5
needs triage charmcraft pack fails with FileNotFoundError when using -p and -o flags for subdirectory charms. Untriaged with zero maintainer interaction in over a year.
qwen3.6-35b-a3b-mtp-q6
Staleness: 85
Complexity: 45
Confidence: 80
Support Request: 5
needs triage charmcraft pack fails with FileNotFoundError when using -p and -o flags to output charms to subdirectories. Untriaged with no maintainer interaction in over a year.
qwen3.6-35b-a3b-mtp-q6
Staleness: 90
Complexity: 30
Confidence: 75
Support Request: 10
close stale charmcraft pack crashes with FileNotFoundError when combining -p and -o flags for subdirectory outputs. Open, unassigned, and inactive for 300+ days. Requires triage and a fix for the path handling logic.

Update history

Date Change
closed

Related issues

Issue Project State Summary Similarity
#2600 fix: make the -p and -o arguments work correctly charmcraft merged Merged fix for charmcraft pack CLI arguments. Corrects -o to function outside the container and -p to properly set the project directory, resolving issue #1930. Approved by reviewers and merged after CI validation.
73%
#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.
71%