Skip to content

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

Description

@gycsaba96

Check existing issues

  • 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'
  1. Run charmcraft pack and observe a successful build.
  2. Remove the charmcraft file from the current dir: rm charmcraft.yaml
  3. 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

Log output

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions