← Back to issue list

Advanced grammar doesn't work with multi-platform (ST124) charms

View original Github issue

Metadata

Project
charmcraft
Number
#2068
Type
issue
State
open
Author
carlcsaposs-canonical
Labels
Created
2025-01-08 11:57:44+00:00
Updated
2025-08-15 15:18:01+00:00
Closed

Current evaluation

No evaluation has been recorded for this issue yet.

Issue body

### Bug Description [Advanced grammar](https://snapcraft.io/docs/snapcraft-advanced-grammar) doesn't work with charms using ST124 syntax (https://docs.google.com/document/d/1QVHxZumruKVZ3yJ2C74qWhvs-ye5I9S6avMBDHs2YcQ/edit?pli=1&tab=t.0#heading=h.sn552414niwh) ### To Reproduce ``` git clone https://github.com/canonical/mysql-router-operator/ cd mysql-router-operator git checkout 4fde81baf3fcf710caa77ae7afcc0e5d51c855af sudo snap install charmcraft --classic --channel latest/edge charmcraft pack -v --platform ubuntu@22.04:amd64 ``` #### Expected behavior `rustup` is installed from snap on 22.04 base #### Actual behavior charmcraft attempts to install `rustup` with apt and fails ``` Starting charmcraft, version 3.2.2.post138+g33519b4a Logging execution to '/home/ubuntu/.local/state/charmcraft/log/charmcraft-20250108-115236.624501.log' Launching managed ubuntu 22.04 instance... Creating new instance from remote Creating new base instance from remote Creating new instance from base instance Starting instance Starting charmcraft, version 3.2.2.post138+g33519b4a Logging execution to '/tmp/charmcraft.log' Initialising lifecycle Installing build-packages Cannot find package listed in 'build-packages': rustup Failed to execute charmcraft in instance. Full execution log: '/home/ubuntu/.local/state/charmcraft/log/charmcraft-20250108-115236.624501.log' ``` ### Environment Ubuntu 22.04 ``` $ snap list Name Version Rev Tracking Publisher Notes charmcraft 3.2.2.post138+g33519b4a 5709 latest/edge canonical✓ classic core18 20240920 2846 latest/stable canonical✓ base core20 20240911 2434 latest/stable canonical✓ base core22 20241119 1722 latest/stable canonical✓ base core24 20240920 609 latest/stable canonical✓ base juju 3.6.1 29241 3/stable canonical✓ - lxd 5.0.4-497fe1e 31333 5.0/stable/… canonical✓ - microk8s v1.29.11 7435 1.29-strict/stable canonical✓ - snapcraft 8.5.1 13181 latest/stable canonical✓ classic snapd 2.66.1 23258 latest/stable canonical✓ snapd ``` ### charmcraft.yaml ```yaml # Copyright 2022 Canonical Ltd. # See LICENSE file for licensing details. type: charm platforms: ubuntu@20.04:amd64: ubuntu@22.04:amd64: ubuntu@22.04:arm64: ubuntu@24.04:amd64: # Files implicitly created by charmcraft without a part: # - dispatch (https://github.com/canonical/charmcraft/pull/1898) # - manifest.yaml # (https://github.com/canonical/charmcraft/blob/9ff19c328e23b50cc06f04e8a5ad4835740badf4/charmcraft/services/package.py#L259) # Files implicitly copied/"primed" by charmcraft without a part: # - actions.yaml, config.yaml, metadata.yaml # (https://github.com/canonical/charmcraft/blob/9ff19c328e23b50cc06f04e8a5ad4835740badf4/charmcraft/services/package.py#L290-L293 # https://github.com/canonical/charmcraft/blob/9ff19c328e23b50cc06f04e8a5ad4835740badf4/charmcraft/services/package.py#L156-L157) parts: # "poetry-deps" part name is a magic constant # https://github.com/canonical/craft-parts/pull/901 poetry-deps: plugin: nil build-packages: - curl override-build: | # Use environment variable instead of `--break-system-packages` to avoid failing on older # versions of pip that do not recognize `--break-system-packages` PIP_BREAK_SYSTEM_PACKAGES=true python3 -m pip install --user --upgrade pip==24.3.1 # renovate: charmcraft-pip-latest # Use uv to install poetry so that a newer version of Python can be installed if needed by poetry curl --proto '=https' --tlsv1.2 -LsSf https://github.com/astral-sh/uv/releases/download/0.5.15/uv-installer.sh | sh # renovate: charmcraft-uv-latest # poetry 2.0.0 requires Python >=3.9 if ! "$HOME/.local/bin/uv" python find '>=3.9' then # Use first Python version that is >=3.9 and available in an Ubuntu LTS # (to reduce number of Python versions we use) "$HOME/.local/bin/uv" python install 3.10.12 # renovate: charmcraft-python-ubuntu-22.04 fi "$HOME/.local/bin/uv" tool install --no-python-downloads --python '>=3.9' poetry==2.0.0 --with poetry-plugin-export==1.8.0 # renovate: charmcraft-poetry-latest ln -sf "$HOME/.local/bin/poetry" /usr/local/bin/poetry # "charm-poetry" part name is arbitrary; use for consistency # Avoid using "charm" part name since that has special meaning to charmcraft charm-poetry: # By default, the `poetry` plugin creates/primes these directories: # - lib, src # (https://github.com/canonical/charmcraft/blob/9ff19c328e23b50cc06f04e8a5ad4835740badf4/charmcraft/parts/plugins/_poetry.py#L76-L78) # - venv # (https://github.com/canonical/charmcraft/blob/9ff19c328e23b50cc06f04e8a5ad4835740badf4/charmcraft/parts/plugins/_poetry.py#L95 # https://github.com/canonical/craft-parts/blob/afb0d652eb330b6aaad4f40fbd6e5357d358de47/craft_parts/plugins/base.py#L270) plugin: poetry source: . after: - poetry-deps poetry-export-extra-args: ['--only', 'main,charm-libs'] build-snaps: - on ubuntu@20.04: - rustup - on ubuntu@22.04: - rustup build-packages: - libffi-dev - libssl-dev - pkg-config - on ubuntu@20.04: [] - on ubuntu@22.04: [] - else: - rustup override-build: | rustup --version rustup default stable craftctl default # Include requirements.txt in *.charm artifact for easier debugging cp requirements.txt "$CRAFT_PART_INSTALL/requirements.txt" # "files" part name is arbitrary; use for consistency files: plugin: dump source: . build-packages: - git override-build: | # Workaround to add unique identifier (git hash) to charm version while specification # DA053 - Charm versioning # (https://docs.google.com/document/d/1Jv1jhWLl8ejK3iJn7Q3VbCIM9GIhp8926bgXpdtx-Sg/edit?pli=1) # is pending review. python3 -c 'import pathlib; import shutil; import subprocess; git_hash=subprocess.run(["git", "describe", "--always", "--dirty"], capture_output=True, check=True, encoding="utf-8").stdout; file = pathlib.Path("charm_version"); shutil.copy(file, pathlib.Path("charm_version.backup")); version = file.read_text().strip(); file.write_text(f"{version}+{git_hash}")' craftctl default prime: - LICENSE - charm_version - workload_version - templates ``` ### Relevant log output [charmcraft-20250108-115236.624501.log](https://github.com/user-attachments/files/18346881/charmcraft-20250108-115236.624501.log)

Evaluation history

No evaluation history available.