← 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

Regression in charmcraft 4.2.1 where 'charmcraft pack -p' fails if both CWD and project directory contain charmcraft.yaml. Untriaged, 101 days old.

Suggested action: needs triage

Reason: The issue is well-structured with clear reproduction steps and identifies a regression between versions 4.0.1 and 4.2.1, but it has no labels, no assignee, and zero maintainer comments after 101 days. It requires maintainer assessment to verify if it is a duplicate of a recent fix (e.g., PR #2600) or a new bug.

Impact: 50 Quick Win: 25.0 Staleness: 65 Complexity: 50 Confidence: 60 Support Request: 10

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
qwen3.6-35b-a3b-mtp-q6
Impact: 50
Quick Win: 25.0
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.
qwen3.6-35b-a3b-mtp-q6
Staleness: 35
Complexity: 40
Confidence: 85
Support Request: 5
needs triage Charmcraft pack fails when both current and target directories contain charmcraft.yaml. Clear reproduction steps and regression details provided. Awaiting maintainer triage.

Update history

No update history recorded yet.

Related work

  • Related To: charmcraft#2600 (confidence 70%)

    PR #2600 recently fixed -p argument handling for project directories; this issue may be a duplicate or a remaining edge case.

Related issues

Issue Project State Summary Similarity
#2498 fix: `charmcraft pack --project-dir` with metadata.yaml charmcraft closed Merged fix for charmcraft pack --project-dir failing with legacy metadata.yaml. Resolved by changing the working directory to the project directory before loading and preprocessing configuration files. Resolves issue #2493.
71%
#2273 charmcraft.yaml deleted while packing (working tree not clean) charmcraft open charmcraft pack deletes charmcraft.yaml from the working tree, making git describe --dirty report -dirty on clean release builds. Reported with charmcraft 3.4.3, no maintainer response or labels in ~13 months.
71%
#2492 Charmcraft crashes with internal error when uploading outside of project directory charmcraft open charmcraft upload crashes with RuntimeError('Project not configured yet.') when run outside a project directory; regression in 4.x from charmlibs warning feature. PR #2497 closed as fix.
71%
#434 Output path changed with charmcraft 1.1.0 charmcraft closed Identified as a regression, the output path change in charmcraft 1.1.0 was fixed. The pack command now correctly outputs to the current directory instead of the project directory.
70%
#1160 `charmcraft pack` does not recognize updated `charmcraft.yaml` file charmcraft open charmcraft pack ignores updated build-snaps channel in charmcraft.yaml without a clean; tracked as a craft-parts bug (canonical/craft-parts#496, still open) awaiting a dependency patch release to pull into charmcraft.
70%