← Back to issue list

Snapcraft fails to build snap if Snapcraft itself is installed using `snap try`

View original Launchpad issue

Metadata

Project
snapcraft (launchpad)
Number
#2014963
Type
issue
State
open
Author
~brlin
Labels
—
Created
Updated
Closed
—

Current evaluation

`snap try` Snapcraft could not self-inject into legacy LXD builds because snapd cannot download a try snap; the affected provider is removed, but current behavior needs retesting.

Suggested action: needs triage

Reason: The report provides a concrete overlay and `snap try --classic` reproduction, with snapd explicitly returning `cannot download file for try-mode snap "snapcraft"`. It has no labels or maintainer response, and the affected legacy injector has been removed while current Craft Providers configuration has no visible try-mode handling, so the scenario needs reproduction against the current implementation.

Evaluated by: mr-cal-bot

Impact: 44 Quick Win: 18 Complexity: 43 Confidence: 80 Actionability: 71

Issue body

I'm testing a small change in the Snapcraft source tree so I make /snap/snapcraft/current writable by using OverlayFS by using the following command: ``` mkdir {upper,work,merged} sudo mount -t overlay overlay -o "lowerdir=/snap/snapcraft/current,upperdir=upper,workdir=work" merged ``` made my change, and install it in try mode using: ``` sudo snap try --classic merged ``` However, when testing the change using a third party snap recipe, Snapcraft errored with the following output: ``` OCRmyPDF - A utility to add an OCR text layer to scanned PDF files, allowing them to be searched on  master via 🐍 v3.8.10 took 5s ❯ snapcraft build ocrmypdf --use-lxd --shell-after --debug Launching a container. Waiting for container to be ready Waiting for network to be ready... Sorry, an error occurred in Snapcraft: 400 Client Error: Bad Request for url: http+unix://%2Frun%2Fsnapd.socket/v2/snaps/snapcraft/file We would appreciate it if you anonymously reported this issue. No other data than the traceback and the version of snapcraft in use will be sent. Would you like to send this error data? (Yes/No/Always/View) [no]: yes Thank you, sent. You can find the traceback in file '/tmp/tmpcfxdmxwa/trace.txt'. OCRmyPDF - A utility to add an OCR text layer to scanned PDF files, allowing them to be searched on  master via 🐍 v3.8.10 took 15s ❯ cat /tmp/tmpcfxdmxwa/trace.txt Traceback (most recent call last):   File "/snap/snapcraft/x1/lib/python3.8/site-packages/snapcraft/cli.py", line 243, in run     _run_dispatcher(dispatcher)   File "/snap/snapcraft/x1/lib/python3.8/site-packages/snapcraft/cli.py", line 219, in _run_dispatcher     dispatcher.run()   File "/snap/snapcraft/x1/lib/python3.8/site-packages/craft_cli/dispatcher.py", line 448, in run     return self._loaded_command.run(self._parsed_command_args)   File "/snap/snapcraft/x1/lib/python3.8/site-packages/snapcraft/commands/lifecycle.py", line 132, in run     parts_lifecycle.run(self.name, parsed_args)   File "/snap/snapcraft/x1/lib/python3.8/site-packages/snapcraft/parts/lifecycle.py", line 178, in run     yaml_data = process_yaml(snap_project.project_file)   File "/snap/snapcraft/x1/lib/python3.8/site-packages/snapcraft/parts/lifecycle.py", line 141, in process_yaml     yaml_data = yaml_utils.load(yaml_file)   File "/snap/snapcraft/x1/lib/python3.8/site-packages/snapcraft/parts/yaml_utils.py", line 92, in load     raise errors.LegacyFallback("base is not core22") snapcraft.errors.LegacyFallback: base is not core22 During handling of the above exception, another exception occurred: Traceback (most recent call last):   File "/snap/snapcraft/x1/lib/python3.8/site-packages/snapcraft_legacy/cli/legacy.py", line 27, in legacy_run     run()   File "/snap/snapcraft/x1/lib/python3.8/site-packages/click/core.py", line 1130, in __call__     return self.main(*args, **kwargs)   File "/snap/snapcraft/x1/lib/python3.8/site-packages/click/core.py", line 1055, in main     rv = self.invoke(ctx)   File "/snap/snapcraft/x1/lib/python3.8/site-packages/click/core.py", line 1657, in invoke     return _process_result(sub_ctx.command.invoke(sub_ctx))   File "/snap/snapcraft/x1/lib/python3.8/site-packages/click/core.py", line 1404, in invoke     return ctx.invoke(self.callback, **ctx.params)   File "/snap/snapcraft/x1/lib/python3.8/site-packages/click/core.py", line 760, in invoke     return __callback(*args, **kwargs)   File "/snap/snapcraft/x1/lib/python3.8/site-packages/snapcraft_legacy/cli/lifecycle.py", line 337, in build     _execute(steps.BUILD, parts, **kwargs)   File "/snap/snapcraft/x1/lib/python3.8/site-packages/snapcraft_legacy/cli/lifecycle.py", line 144, in _execute     with build_provider_class(   File "/snap/snapcraft/x1/lib/python3.8/site-packages/snapcraft_legacy/internal/build_providers/_base_provider.py", line 87, in __enter__     self.create()   File "/snap/snapcraft/x1/lib/python3.8/site-packages/snapcraft_legacy/internal/build_providers/_lxd/_lxd.py", line 284, in create     self.launch_instance()   File "/snap/snapcraft/x1/lib/python3.8/site-packages/snapcraft_legacy/internal/build_providers/_base_provider.py", line 263, in launch_instance     self._setup_snapcraft()   File "/snap/snapcraft/x1/lib/python3.8/site-packages/snapcraft_legacy/internal/build_providers/_lxd/_lxd.py", line 482, in _setup_snapcraft     super()._setup_snapcraft()   File "/snap/snapcraft/x1/lib/python3.8/site-packages/snapcraft_legacy/internal/build_providers/_base_provider.py", line 510, in _setup_snapcraft     snap_injector.apply()   File "/snap/snapcraft/x1/lib/python3.8/site-packages/snapcraft_legacy/internal/build_providers/_snap.py", line 392, in apply     snap.push_host_snap(file_pusher=self._file_pusher)   File "/snap/snapcraft/x1/lib/python3.8/site-packages/snapcraft_legacy/internal/build_providers/_snap.py", line 141, in push_host_snap     host_snap_repo.local_download(   File "/snap/snapcraft/x1/lib/python3.8/site-packages/snapcraft_legacy/internal/repo/snaps.py", line 199, in local_download     snap_file_iter = _get_local_snap_file_iter(self.name, chunk_size=1024)   File "/snap/snapcraft/x1/lib/python3.8/site-packages/snapcraft_legacy/internal/repo/snaps.py", line 365, in _get_local_snap_file_iter     snap_file.raise_for_status()   File "/snap/snapcraft/x1/lib/python3.8/site-packages/requests/models.py", line 1021, in raise_for_status     raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: http+unix://%2Frun%2Fsnapd.socket/v2/snaps/snapcraft/file ``` Here's the response of http+unix://%2Frun%2Fsnapd.socket/v2/snaps/snapcraft/file: ``` ❯ http http+unix://%2Frun%2Fsnapd.socket/v2/snaps/snapcraft/file HTTP/1.1 400 Bad Request Content-Length: 133 Content-Type: application/json Date: Sat, 01 Apr 2023 13:53:04 GMT {     "result": {         "message": "cannot download file for try-mode snap \"snapcraft\""     },     "status": "Bad Request",     "status-code": 400,     "type": "error" } ``` It seems that Snapcraft tries to inject itself's snap package into the built environment, and fails due to the package file doesn't exist in the first place. It would be great if Snapcraft could detect such a situation and workaround it somehow(like pack itself to a new snap package and inject that package instead), making testing small code changes possible, or at least error in a friendlier, more specific, error message.

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha
Impact: 44
Quick Win: 18
Complexity: 43
Confidence: 80
Actionability: 71
needs triage `snap try` Snapcraft could not self-inject into legacy LXD builds because snapd cannot download a try snap; the affected provider is removed, but current behavior needs retesting.
stealth/space-bunny-alpha
Impact: 38
Quick Win: 11
Complexity: 53
Confidence: 75
Actionability: 64
needs triage Snap try installations break LXD self-injection when snapd cannot download Snapcraft; this untriaged report targets the removed legacy provider and needs verification against current build paths.
qwen3.6-35b-a3b-mtp-q6
Impact: 30
Quick Win: 18
Staleness: 95
Complexity: 40
Confidence: 60
Support Request: 10
close stale Snapcraft fails when using snap try due to snapd not allowing file downloads for try-mode snaps. Issue is 1251 days old with no maintainer engagement.
qwen/qwen3.6-35b-a3b
Staleness: 95
Complexity: 40
Confidence: 85
Support Request: 10
close stale Bug report detailing a build failure when using a `snap try` installed Snapcraft. The issue is over three years old, unlabelled, and has had no maintainer interaction.
qwen/qwen3.6-35b-a3b
Staleness: 95
Complexity: 60
Confidence: 90
Support Request: 10
close stale Snapcraft build fails when Snapcraft is installed via `snap try` because it tries to inject its own snap file which doesn't exist. Issue is 3+ years old with no activity.
qwen3.6-35b-a3b-mtp-q6
Staleness: 92
Complexity: 35
Confidence: 85
Support Request: 15
needs triage Snapcraft fails when installed via snap try because it cannot fetch its own snap file for injection into build containers. Untriaged and inactive for over 3 years.

Update history

Date Change
created

Related work

  • Duplicate Of: snapcraft (launchpad)#1892551 (confidence 93%)

    Another open issue reports LXD builds failing from a try snap because snapd cannot export or download the try-snap file.

  • Related To: snapcraft#2524 (confidence 88%)

    Merged PR #2524 added a dedicated `snapcraft try` workflow, but it is not evidence that the reported `snap try` LXD failure was fixed.

Related issues

Issue Project State Summary Similarity
#1892551 snapcraft fails to run if it is installed as a try snap snapcraft (launchpad) open Snapcraft 4.1.5 failed in LXD builds when launched via snap try because snapd cannot export a try-snap file; the affected legacy provider is absent from the current codebase.
89%
#1795827 Snapcraft doesn't install snapcraft inside the lxd container snapcraft (launchpad) open Historical LXD builds failed because Snapcraft was not injected into the container; the modern Craft Providers LXD path injects Snapcraft and resolves the legacy failure.
79%
#2524 Snapcraft try snapcraft merged Merged snapcraft try via PR #2524 (commit ec579eaa1); LXD tests were split out because they require Snapcraft installed from the store.
76%
#1746612 Snapcraft cleanbuild doesn't work if you're not using the LXD snap snapcraft (launchpad) closed Closed after the missing hostfs behavior was fixed upstream in lxc/lxd#4183. Snapcraft PR #1912 offered a workaround but was not merged.
74%
#1825820 Snapcraft doesn't update the `snapcraft-project` disk source when the path is moved snapcraft (launchpad) open LXD builds reportedly fail after moving a project because the instance retains the old disk source. LXD remains supported, but this untriaged report needs verification against the current craft-providers integration.
72%
#1729069 snapcraft container builds with snap try snapcraft (launchpad) closed Closed without a documented fix; snap try failing when container builds are enabled remained unresolved and was abandoned after years of inactivity.
72%
#1996508 snapcraft try with core22 doesn't support lxd snapcraft (launchpad) closed Core22 support for snapcraft try --use-lxd was added by merged PR snapcore/snapcraft#3981 (commit 2691262b8) and released on edge.
72%
#1839399 snapcraft not pulling snap from lxd container snapcraft (launchpad) open Snapcraft 3.7.1 reported a successful --use-lxd build but left the generated snap absent on the host; a maintainer identified possible CWD handling, and the case remains unresolved.
72%
#2099923 Snapcraft builds are failing: install of snap "snapcraft" failed snapcraft (launchpad) open Reported Launchpad Bionic non-i386 builds cannot install Snapcraft 7.x/stable because core20 needs snapd 2.61; the issue remains open, untriaged, and unanswered.
72%
#719 Snapcraft fails initialization of build container craft-providers closed LXD startup race was fixed by waiting for instance readiness in craft-providers PR #720; the fix shipped via Snapcraft PR #5247 in Snapcraft 8.6.2.
71%