Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions snapcraft/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,19 @@ def _get_esm_error_for_base(base: str) -> None:
)


def _get_base_warning_for_base(base: str) -> None:
"""Emit a warning to use Snapcraft 9.x for core22, core24, and core26 bases."""
match base:
case "core22" | "core24" | "core26":
emit.warning(
f"Base {base!r} is supported in Snapcraft 9.x. "
"It is recommended to upgrade to Snapcraft 9.x via the 'latest/stable' channel "
"to benefit from the latest bug fixes and performance improvements."
Comment on lines +92 to +94

@mr-cal mr-cal May 7, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is my suggestion, but let's wait for feedback from @canonical/starcraft-authors:

Suggested change
f"Base {base!r} is supported in Snapcraft 9.x. "
"It is recommended to upgrade to Snapcraft 9.x via the 'latest/stable' channel "
"to benefit from the latest bug fixes and performance improvements."
f"Snapcraft 9 is recommended for {base!r}. "
"Upgrade to Snapcraft 9 for the latest bug fixes and improvements."

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure! I'll wait for feedback from @canonical/starcraft-authors first.
Please let me know once there's a decision, as the test file will need
to be updated as well.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The format looks good, with some things to consider:

  • "update" might be better than "upgrade", since the latter can suggest more of a toll for the user.
  • Wildcard: how would you feel about "refresh" to match the command name?
  • I would go with "features and improvements".

)
case _:
return


class Snapcraft(Application):
"""Snapcraft application definition."""

Expand Down Expand Up @@ -174,6 +187,7 @@ def _pre_run(self, dispatcher: craft_cli.Dispatcher) -> None:
)
_get_esm_error_for_base(effective_base)
self._ensure_remote_build_supported(effective_base)
_get_base_warning_for_base(effective_base)

super()._pre_run(dispatcher)

Expand Down
12 changes: 12 additions & 0 deletions tests/unit/test_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,18 @@ def test_esm_pass(mocker, snapcraft_yaml, base):
mock_dispatch.assert_called_once()


@pytest.mark.parametrize("base", ["core22", "core24", "core26"])
def test_get_base_warning_for_base_emits_message(emitter, base):
"""Test that _get_base_warning_for_base emits the correct message for core22, core24, and core26."""
application._get_base_warning_for_base(base)

emitter.assert_warning(
f"Base {base!r} is supported in Snapcraft 9.x. "
"It is recommended to upgrade to Snapcraft 9.x via the 'latest/stable' channel "
"to benefit from the latest bug fixes and performance improvements."
)


def test_yaml_syntax_error(in_project_path, monkeypatch, capsys):
"""Provide a user friendly error on yaml syntax errors."""
(in_project_path / "snapcraft.yaml").write_text("bad:\nyaml")
Expand Down
Loading