← Back to issue list

Charmcraft confuses the current directory with the project directory when both has a charmcraft.yaml

View original Github issue

Metadata

Project
charmcraft
Number
#2707
Type
issue
State
open
Author
gycsaba96
Labels
—
Created
Updated
Closed
—

Current evaluation

Charmcraft 4.2.1 mixed the CWD and -p project files when both had charmcraft.yaml, breaking nested pack builds and CI; targeted project-directory fixes are present in current code.

Suggested action: close resolved

Reason: The current Charmcraft._run_inner code reads the requested -p directory, updates the project service, and evicts a service cached with the CWD; commit 5e634d96 (PR #2600) explicitly fixes -p and -o handling. Commit c87eca0d (PR #2644) also fixes metadata lookup from the selected project directory, directly covering the reported path mixing.

Evaluated by: mr-cal-bot

Impact: 58 Quick Win: 23 Complexity: 52 Confidence: 84 Actionability: 84

Issue body

### Check existing issues - [x] I've verified that this bug isn't described by any existing issues. ### Bug description When both the current working directory and the project directory provided by -p contain a charmcraft.yaml, charmcraft gets confused (somehow mixes the two and fails). ### Steps to reproduce 1. Clone and enter `https://github.com/canonical/istio-beacon-k8s-operator.git` 2. Run `charmcraft pack -p ./tests/integration/testers/service-mesh-tester` 3. Observe an error: ``` ubuntu@microk8s-vm:~/istio-beacon-k8s-operator$ charmcraft pack -p ./tests/integration/testers/service-mesh-tester Platform 'ubuntu@22.04:amd64' not found in the project definition. Detailed information: Valid platforms are: 'ubuntu-20.04-amd64'. Failed to run charmcraft in instance Full execution log: '/home/ubuntu/.local/state/charmcraft/log/charmcraft-20260526-184109.244315.log' ``` 4. Run `charmcraft pack` and observe a successful build. 5. Remove the charmcraft file from the current dir: `rm charmcraft.yaml` 6. Run `charmcraft pack -p ./tests/integration/testers/service-mesh-tester` and see it succeed. ### Environment Charmcraft version: 4.2.1 OS: Ubuntu 24.04 (inside my development VM) (It worked before updating from 4.0.1 to 4.2.1) It also fails CI pipelines with a similar setup. ### charmcraft.yaml ```yaml ``` ### Log output ```shell ```

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha
Impact: 58
Quick Win: 23
Complexity: 52
Confidence: 84
Actionability: 84
close resolved Charmcraft 4.2.1 mixed the CWD and -p project files when both had charmcraft.yaml, breaking nested pack builds and CI; targeted project-directory fixes are present in current code.
stealth/space-bunny-alpha
Impact: 57
Quick Win: 25
Complexity: 48
Confidence: 84
Actionability: 85
needs triage Charmcraft 4.2.1 regression: `pack -p` fails when the working directory and selected project directory both contain charmcraft.yaml, potentially breaking CI builds.
qwen3.6-35b-a3b-mtp-q6
Impact: 50
Quick Win: 25
Staleness: 65
Complexity: 50
Confidence: 60
Support Request: 10
needs triage Regression in charmcraft 4.2.1 where 'charmcraft pack -p' fails if both CWD and project directory contain charmcraft.yaml. Untriaged, 101 days old.
qwen/qwen3.6-35b-a3b
Staleness: 65
Complexity: 35
Confidence: 90
Support Request: 5
needs triage Bug where charmcraft pack fails when both current and target directories contain charmcraft.yaml. Regression from v4.0.1 to v4.2.1. Untriaged, no maintainer comments.
qwen3.6-35b-a3b-mtp-q6
Staleness: 65
Complexity: 45
Confidence: 90
Support Request: 10
needs triage charmcraft pack -p fails when both current and target directories contain charmcraft.yaml. Regression from v4.0.1 to v4.2.1. Untriaged, no maintainer response.

Update history

No update history recorded yet.

Related work

  • Likely Fixed By: canonical/charmcraft#2600 (confidence 93%)

    Commit 5e634d96 changes -p/-o handling and removes the project service cached with the CWD.

  • Related To: canonical/charmcraft#2644 (confidence 88%)

    Merged commit c87eca0d fixes metadata lookup using the selected project directory; the PR is documented as resolving #2493.

Related issues

Issue Project State Summary Similarity
#434 Output path changed with charmcraft 1.1.0 charmcraft closed Charmcraft’s 1.1.0 pack regression was fixed, again writing the packed charm to the current working directory rather than the --project-dir directory.
74%
#2854 charmcraft pack ignores -o option in version 4.4.1 charmcraft open charmcraft 4.4.1 `pack -o .` does not place the charm in the -o folder when --project-dir points outside cwd. Exact repro given, but reported output location unspecified. Unlabelled, no maintainer response in 36 days.
73%
#2498 fix: `charmcraft pack --project-dir` with metadata.yaml charmcraft closed Closed unmerged; superseded by #2644, which fixed metadata lookup for --project-dir and shipped in Charmcraft 4.2.1.
72%
#514 `charmcraft build` silently omits files called out in `charmcraft.yaml` if executed from an external directory charmcraft closed Fixed by merged PR canonical/charmcraft#525 (merge commit 0d78f540), which runs the parts lifecycle from the project directory so relative globbed paths resolve during external builds.
72%
#433 charmcraft --project-dir does not work for build anymore charmcraft closed Closed as working as designed: maintainer facundobatista explained `build` selects its project dir with `--from`, not `--project-dir` (which `pack` uses), so `charmcraft build --from charm-slurmd/` works.
72%
#198 `charmcraft init` would be better off with explicit directory name charmcraft closed Kept directory selection on --project-dir; missing directories are now created by #508 (commit 15d530ae).
71%
#1149 command: charmcraft init to use charmcraft.yaml only charmcraft merged Merged in ca4df024: charmcraft init now generates a unified charmcraft.yaml containing metadata, actions, and config, with profile descriptions and an updated URL.
70%