← Back to issue list

Multiple `charmcraft pack` fail on mismatching platforms

View original Github issue

Metadata

Project
charmcraft
Number
#2631
Type
issue
State
open
Author
simondeziel
Labels
Created
Updated
Closed

Current evaluation

Charmcraft 4.2.0+ reuses a managed LXD instance from a prior `charmcraft pack` of a different project, causing the second pack to fail with 'Platform not found in the project definition' when platform sets differ. Still reproducible on 4.3.1 per reporter's 2026-08-17 comment; no maintainer response or labels yet.

Suggested action: needs triage

Reason: The issue has no labels, no assignee, and no maintainer comments — only the reporter's own follow-up (2026-08-17) confirming it persists on 4.3.1. It's a clear regression (worked in 4.0.1, broke in 4.2.0) with a concrete reproducer (two consecutive `charmcraft pack` calls with different platform sets), so it needs maintainer triage rather than closure. Complexity is moderate because the root cause likely lies in craft-providers' instance/base-instance reuse logic (the 'Creating instance from base instance' step) rather than charmcraft's own code, which I could not locate in this repo's source.

Impact: 65 Quick Win: 26.0 Staleness: 15 Complexity: 60 Confidence: 70 Support Request: 5

Issue body

### Check existing issues - [x] I've verified that this bug isn't described by any existing issues. ### Bug description With Charmcraft 4.0.1, the [charm-lxd](https://github.com/canonical/charm-lxd) CI was building the primary LXD charm for 24.04 and 22.04 followed by an ancillary charm for 24.04 only one: ``` charmcraft pack -v echo "==> ancillary charm for testing purposes" charmcraft pack -v --project-dir examples/https-client ``` Now with Charmcraft 4.2.0, packing the ancillary charm fails with: ``` Staging charm Priming charm Packing... Packing charm https-client_ubuntu-24.04-amd64.charm Packed https-client_ubuntu-24.04-amd64.charm Launching managed ubuntu 22.04 instance... Creating instance from base instance Starting instance Starting charmcraft, version 4.2.0 Logging execution to '/tmp/charmcraft.log' Platform 'ubuntu-22.04-amd64' not found in the project definition. Detailed information: Valid platforms are: 'ubuntu-24.04-amd64', 'ubuntu-24.04-arm64', 'ubuntu-24.04-armhf', 'ubuntu-24.04-ppc64el', 'ubuntu-24.04-riscv64', 'ubuntu-24.04-s390x'. Failed to run charmcraft in instance ``` The full logs: https://github.com/canonical/charm-lxd/actions/runs/23904129367/job/69708427467 The [main `charmcraft.yaml`](https://github.com/canonical/charm-lxd/blob/b7b57f9660d77c242afc348a26b49b7bed6dcc0e/charmcraft.yaml) and the [anciliary `charmcraft.yaml`](https://github.com/canonical/charm-lxd/blob/b7b57f9660d77c242afc348a26b49b7bed6dcc0e/examples/https-client/charmcraft.yaml) ### Steps to reproduce Build 2 charms consecutively. The first with: ``` type: charm platforms: ubuntu-24.04-amd64: build-on: [ubuntu@24.04:amd64] build-for: [ubuntu@24.04:amd64] ubuntu-22.04-arm64: build-on: [ubuntu@22.04:amd64] build-for: [ubuntu@22.04:amd64] ``` And the second with: ``` type: charm platforms: ubuntu-24.04-amd64: build-on: [ubuntu@24.04:amd64] build-for: [ubuntu@24.04:amd64] ```

Evaluation history

Date Model Scores Action Summary
qwen/qwen3.8-27b
Impact: 65
Quick Win: 26.0
Staleness: 15
Complexity: 60
Confidence: 70
Support Request: 5
needs triage Charmcraft 4.2.0+ reuses a managed LXD instance from a prior `charmcraft pack` of a different project, causing the second pack to fail with 'Platform not found in the project definition' when platform sets differ. Still reproducible on 4.3.1 per reporter's 2026-08-17 comment; no maintainer response or labels yet.
qwen/qwen3.6-35b-a3b
Staleness: 25
Complexity: 45
Confidence: 90
Support Request: 10
needs triage Regression in Charmcraft 4.2.0+ where packing an ancillary charm fails with a platform mismatch error when run after a primary charm with different platforms. Currently unlabelled and awaiting maintainer review.
qwen3.6-35b-a3b-mtp-q6
Staleness: 70
Complexity: 40
Confidence: 85
Support Request: 10
needs triage Regression in Charmcraft 4.2.0 where packing a secondary charm fails with a platform mismatch error when run after a primary charm. Untriaged, no maintainer response after 110 days.
qwen3.6-35b-a3b-mtp-q6
Staleness: 75
Complexity: 50
Confidence: 90
Support Request: 10
needs triage Regression in Charmcraft 4.2.0 where consecutive charmcraft pack commands fail due to platform state leakage. Ancillary charm incorrectly expects a platform from the previously built charm. Untriaged, no maintainer response.
qwen3.6-35b-a3b-mtp-q6
Staleness: 55
Complexity: 60
Confidence: 85
Support Request: 10
needs triage charmcraft pack fails when building multiple charms consecutively with mismatching platforms, incorrectly reusing a managed instance from a previous build. Untriaged, no maintainer response.
qwen3.6-35b-a3b-mtp-q6
Staleness: 55
Complexity: 45
Confidence: 90
Support Request: 10
needs triage Consecutive charmcraft pack commands leak platform state between projects, causing subsequent builds to fail with a platform mismatch error. Regression in 4.2.0. Open, unassigned, awaiting triage.

Update history

Date Change
updated

Related issues

Issue Project State Summary Similarity
#1104 charmcraft pack on Ubuntu 23.04 (Lunar) fails. charmcraft closed Charmcraft pack failed on Ubuntu 23.04 due to unavailable build environments. PR #1130 addressed the issue but was blocked by an external cloud-images bug. The issue was closed pending upstream resolution.
71%
#2078 `charmcraft clean` does not clean all platforms for charm charmcraft open charmcraft clean only removes LXC containers for platforms currently listed in charmcraft.yaml, leaving stale containers for removed platforms. Reported with repro steps; linked to issue #1338 in Jan 2025, no further activity.
70%