← Back to issue list

Go plugin environment validation fails if toolchain downloads a new version

View original Github issue

Metadata

Project
rockcraft
Number
#902
Type
issue
State
open
Author
hk21702
Labels
—
Created
Updated
Closed
—

Current evaluation

Go plugin env validation fails when `go version` triggers toolchain auto-download; stderr download message is parsed as the version. Root cause is in craft-parts validator; duplicate craft-parts#1447 is open.

Suggested action: needs triage

Reason: The issue has no labels, comments, or maintainer assessment in rockcraft, so it has not been triaged. The log clearly shows `go: downloading go1.24.4` being treated as the compiler version, and craft-parts' `validate_dependency` returns stderr preferentially, confirming the root cause; the same bug is tracked in canonical/craft-parts#1447.

Evaluated by: mr-cal-bot

Impact: 60 Quick Win: 36 Complexity: 25 Confidence: 85 Actionability: 80

Issue body

### Bug Description The Go plugin's validation step will fail if the go toolchain downloads a version different from that of the bundled Go toolchain. This seems to be due to `rockcraft` being unable to correctly parse the output if go is in the middle of pulling a different toolchain version. The workaround I've found is to set `GOTOOLCHAIN: local` (though this does only work if your application will work with gotoolchain set as local) or to run `rockcraft pack` twice, as the correct toolchain will be local in the build environment on the second call. The latter workaround, while fine for development environments, is not all that viable for CI workflows. ### To Reproduce Start with a go project which targets a toolchain version that differs from what would be available locally. For example, in `go.mod`: ``` go 1.24.0 toolchain go1.24.4 ``` Then have a part using the `go` plugin while using a go dependency that doesn't match with the requested toolchain version. For example, the build-snap `go/1.24/stable` (At the time of writing, the snap is still at 1.24.2). ``` web-service: plugin: go source: . source-subdir: cmd/web-service build-snaps: - go/1.24/stable stage: - bin/web-service ``` Run ``` rockcraft clean rockcraft pack ``` ### Environment I'm running within a Multipass Ubuntu 24.04.02 instance rockcraft 1.12.0 This issue also occurs if using the `canonical/craft-actions/rockcraft-pack@main` workflow on an `ubuntu-24.04` GitHub runner. ### rockcraft.yaml ```yaml name: ubuntu-insights-services base: ubuntu@24.04 version: "0.17" # just for humans. Semantic versioning is recommended license: GPL-3.0 summary: Service for ubuntu-insights # 79 char long summary description: | Ubuntu Insights services used for accepting HTTP requests with insights reports from clients, validating them, and inserting them into a database. This service is part of the Ubuntu Insights project, a transparent, user-friendly, open, platform-agnostic, and cross-application solution for reporting hardware information and other collected metrics. # the platforms this rock should be built on and run on. # you can check your architecture with `dpkg --print-architecture` platforms: amd64: services: web-service: override: replace command: web-service startup: disabled ingest-service: override: replace command: ingest-service startup: disabled run-user: _daemon_ # setting a non-root user for the rock parts: web-service: plugin: go source: . source-subdir: cmd/web-service build-snaps: - go/1.24/stable stage: - bin/web-service ingest-service: plugin: go source: . source-subdir: cmd/ingest-service build-snaps: - go/1.24/stable stage: - bin/ingest-service migrations: plugin: dump source: . source-subdir: migrations organize: "*": usr/share/insights/migrations/ stage: - usr/share/insights/migrations/* golang-migrate: plugin: dump source: https://github.com/golang-migrate/migrate/releases/download/v4.18.3/migrate.linux-amd64.deb source-type: deb ``` ### Relevant log output ```shell ## Plugin environment export GOBIN="/root/parts/ingest-service/install/bin" ## User environment 2025-06-18 13:50:12.657 plugin validation command: 'go version' 2025-06-18 13:50:17.291 executed go version with output go: downloading go1.24.4 (linux/amd64) 2025-06-18 13:50:17.291 Environment validation failed for part 'ingest-service': invalid go compiler version 'go: downloading go1.24.4 (linux/amd64)'. 2025-06-18 13:50:17.294 Traceback (most recent call last): 2025-06-18 13:50:17.294 File "/snap/rockcraft/3367/lib/python3.12/site-packages/craft_application/services/lifecycle.py", line 305, in run 2025-06-18 13:50:17.294 with self._lcm.action_executor() as aex: 2025-06-18 13:50:17.294 File "/snap/rockcraft/3367/lib/python3.12/site-packages/craft_parts/executor/executor.py", line 306, in __enter__ 2025-06-18 13:50:17.294 self._executor.prologue() 2025-06-18 13:50:17.294 File "/snap/rockcraft/3367/lib/python3.12/site-packages/craft_parts/executor/executor.py", line 91, in prologue 2025-06-18 13:50:17.294 self._verify_plugin_environment() 2025-06-18 13:50:17.294 File "/snap/rockcraft/3367/lib/python3.12/site-packages/craft_parts/executor/executor.py", line 292, in _verify_plugin_environment 2025-06-18 13:50:17.294 validator.validate_environment(part_dependencies=part.dependencies) 2025-06-18 13:50:17.294 File "/snap/rockcraft/3367/lib/python3.12/site-packages/craft_parts/plugins/go_plugin.py", line 72, in validate_environment 2025-06-18 13:50:17.295 raise errors.PluginEnvironmentValidationError( 2025-06-18 13:50:17.295 craft_parts.errors.PluginEnvironmentValidationError: Environment validation failed for part 'ingest-service': invalid go compiler version 'go: downloading go1.24.4 (linux/amd64)'. 2025-06-18 13:50:17.403 Emitter: Resuming control of the terminal 2025-06-18 13:50:17.403 Executing in container: lxc --project rockcraft exec local:rockcraft-ubuntu-insights-services-amd64-531901 -- env CRAFT_MANAGED_MODE=1 DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true DEBIAN_PRIORITY=critical test -f /tmp/rockcraft.log 2025-06-18 13:50:17.517 Executing on host: lxc --project rockcraft file pull local:rockcraft-ubuntu-insights-services-amd64-531901/tmp/rockcraft.log /home/runner/tmpl4m831j0.tmp-craft/tmpr1sttxbx 2025-06-18 13:50:17.592 Logs retrieved from managed instance: 2025-06-18 13:50:17.593 Executing in container: lxc --project rockcraft exec local:rockcraft-ubuntu-insights-services-amd64-531901 -- env CRAFT_MANAGED_MODE=1 DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true DEBIAN_PRIORITY=critical test -f /tmp/rockcraft-pack.yaml 2025-06-18 13:50:17.859 Could not find state file /tmp/rockcraft-pack.yaml in instance. 2025-06-18 13:50:17.859 Executing on host: lxc --project rockcraft config device show local:rockcraft-ubuntu-insights-services-amd64-531901 2025-06-18 13:50:17.928 Executing on host: lxc --project rockcraft config device remove local:rockcraft-ubuntu-insights-services-amd64-531901 disk-/root/project 2025-06-18 13:50:18.140 Executing on host: lxc --project rockcraft stop local:rockcraft-ubuntu-insights-services-amd64-531901 2025-06-18 13:50:22.016 Executing on host: lxc --project rockcraft list local: --format=yaml 2025-06-18 13:50:22.087 Executing on host: lxc --project rockcraft list local: --format=yaml 2025-06-18 13:50:22.162 Failed to run rockcraft in instance 2025-06-18 13:50:22.168 Traceback (most recent call last): 2025-06-18 13:50:22.168 File "/snap/rockcraft/3367/lib/python3.12/site-packages/craft_application/services/provider.py", line 448, in run_managed 2025-06-18 13:50:22.168 instance.execute_run( # pyright: ignore[reportUnknownMemberType,reportUnknownVariableType] 2025-06-18 13:50:22.168 File "/snap/rockcraft/3367/lib/python3.12/site-packages/craft_providers/lxd/lxd_instance.py", line 254, in execute_run 2025-06-18 13:50:22.168 return self.lxc.exec( 2025-06-18 13:50:22.168 ^^^^^^^^^^^^^^ 2025-06-18 13:50:22.169 File "/snap/rockcraft/3367/lib/python3.12/site-packages/craft_providers/lxd/lxc.py", line 390, in exec 2025-06-18 13:50:22.169 return runner(final_cmd, timeout=timeout, check=check, **kwargs) 2025-06-18 13:50:22.169 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2025-06-18 13:50:22.169 File "/snap/rockcraft/current/usr/lib/python3.12/subprocess.py", line 571, in run 2025-06-18 13:50:22.169 raise CalledProcessError(retcode, process.args, 2025-06-18 13:50:22.169 subprocess.CalledProcessError: Command '['lxc', '--project', 'rockcraft', 'exec', 'local:rockcraft-ubuntu-insights-services-amd64-531901', '--cwd', '/root/project', '--', 'env', 'CRAFT_MANAGED_MODE=1', 'DEBIAN_FRONTEND=noninteractive', 'DEBCONF_NONINTERACTIVE_SEEN=true', 'DEBIAN_PRIORITY=critical', 'CRAFT_PLATFORM=amd64', 'CRAFT_VERBOSITY_LEVEL=TRACE', 'rockcraft', 'pack', '--verbosity', 'trace']' returned non-zero exit status 1. 2025-06-18 13:50:22.169 2025-06-18 13:50:22.169 The above exception was the direct cause of the following exception: 2025-06-18 13:50:22.169 Traceback (most recent call last): 2025-06-18 13:50:22.169 File "/snap/rockcraft/3367/lib/python3.12/site-packages/craft_application/application.py", line 615, in run 2025-06-18 13:50:22.169 return_code = self._run_inner() 2025-06-18 13:50:22.169 ^^^^^^^^^^^^^^^^^ 2025-06-18 13:50:22.169 File "/snap/rockcraft/3367/lib/python3.12/site-packages/craft_application/application.py", line 594, in _run_inner 2025-06-18 13:50:22.169 return_code = dispatcher.run() or os.EX_OK 2025-06-18 13:50:22.169 ^^^^^^^^^^^^^^^^ 2025-06-18 13:50:22.169 File "/snap/rockcraft/3367/lib/python3.12/site-packages/craft_cli/dispatcher.py", line 528, in run 2025-06-18 13:50:22.169 return self._loaded_command.run(self._parsed_command_args) 2025-06-18 13:50:22.169 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2025-06-18 13:50:22.169 File "/snap/rockcraft/3367/lib/python3.12/site-packages/craft_application/commands/base.py", line 199, in run 2025-06-18 13:50:22.169 result = self._run(parsed_args, **kwargs) or result 2025-06-18 13:50:22.169 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2025-06-18 13:50:22.169 File "/snap/rockcraft/3367/lib/python3.12/site-packages/craft_application/commands/lifecycle.py", line 475, in _run 2025-06-18 13:50:22.169 return super()._run(parsed_args=parsed_args, step_name=step_name) 2025-06-18 13:50:22.169 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2025-06-18 13:50:22.169 File "/snap/rockcraft/3367/lib/python3.12/site-packages/craft_application/commands/lifecycle.py", line 181, in _run 2025-06-18 13:50:22.169 self._run_manager_for_build_plan(fetch_service_policy) 2025-06-18 13:50:22.169 File "/snap/rockcraft/3367/lib/python3.12/site-packages/craft_application/commands/lifecycle.py", line 90, in _run_manager_for_build_plan 2025-06-18 13:50:22.169 provider.run_managed(build, bool(fetch_service_policy)) 2025-06-18 13:50:22.169 File "/snap/rockcraft/3367/lib/python3.12/site-packages/craft_application/services/provider.py", line 455, in run_managed 2025-06-18 13:50:22.169 raise craft_providers.ProviderError( 2025-06-18 13:50:22.169 craft_providers.errors.ProviderError: Failed to run rockcraft in instance 2025-06-18 13:50:22.169 Full execution log: '/home/runner/.local/state/rockcraft/log/rockcraft-20250618-134850.295022.log' ```

Evaluation history

Date Model Scores Action Summary
~deepseek/deepseek-pro-latest
Impact: 60
Quick Win: 36
Complexity: 25
Confidence: 85
Actionability: 80
needs triage Go plugin env validation fails when `go version` triggers toolchain auto-download; stderr download message is parsed as the version. Root cause is in craft-parts validator; duplicate craft-parts#1447 is open.
qwen/qwen3.6-35b-a3b
Impact: 45
Quick Win: 20
Complexity: 40
Confidence: 75
Actionability: 75
keep open Go plugin env validation fails when `go version` triggers toolchain auto-download, because the download message is captured as output instead of the version string. Issue open in craft-parts#1447.
qwen/qwen3.8-27b
Impact: 45
Quick Win: 25
Staleness: 85
Complexity: 45
Confidence: 80
Support Request: 5
needs triage Go plugin environment validation fails when `go version` triggers a Go toolchain auto-download, printing 'go: downloading...' instead of a version string. Open 439 days with no labels or maintainer activity; bug still present in craft-parts go_plugin validator.
qwen/qwen3.6-35b-a3b
Staleness: 88
Complexity: 25
Confidence: 80
Support Request: 5
needs triage Go plugin environment validation fails when `go version` triggers a toolchain download, causing a parsing error. Unlabelled and untouched for over a year.
qwen3.6-35b-a3b-mtp-q6
Staleness: 95
Complexity: 30
Confidence: 85
Support Request: 5
needs triage Go plugin environment validation fails when go version triggers a toolchain download, causing parsing errors. Open for 384 days with no maintainer response or labels.
qwen3.6-35b-a3b-mtp-q6
Staleness: 90
Complexity: 25
Confidence: 85
Support Request: 5
needs triage Go plugin environment validation fails when go version triggers a toolchain download, causing rockcraft to misparse the output. Untriaged, no maintainer response in over a year.

Update history

No update history recorded yet.

Related work

  • Duplicate Of: canonical/craft-parts#1447 (confidence 90%)

    Same root cause: craft-parts go_plugin validator returns the stderr toolchain-download message instead of the stdout version output.

Related issues

Issue Project State Summary Similarity
#1447 snap build fails if go must download the version craft-parts open Go plugin validation misreads a toolchain-download message from stderr as the compiler version, so the first clean snapcraft pack fails while retries succeed; it remains unfixed and untriaged.
74%