Snapcraft fails to build snap if Snapcraft itself is installed using `snap try`
Metadata
Current evaluation
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.
Suggested action: close stale
Reason: The issue is 1251 days old with no maintainer engagement and references legacy code paths (snapcraft_legacy) that may no longer exist in the current snapcraft architecture. The specific error path causing this issue has likely changed significantly, and the underlying snapd limitation (cannot download file for try-mode snap) remains but may not affect the current codebase in the same way.
Impact:
30
Quick Win:
18.0
Staleness:
95
Complexity:
40
Confidence:
60
Support Request:
10
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 |
|---|---|---|---|---|
| qwen3.6-35b-a3b-mtp-q6 |
Impact:
30
Quick Win:
18.0
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. | |
| qwen3.6-35b-a3b-mtp-q6 |
Staleness:
95
Complexity:
35
Confidence:
85
Support Request:
15
|
close stale | Snapcraft fails when installed via snap try because it cannot inject its own snap file into build containers. Issue is 3+ years old with no maintainer response. |
Update history
No update history recorded yet.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #2099923 Snapcraft builds are failing: install of snap "snapcraft" failed | snapcraft (launchpad) | open | Snapcraft builds failing due to outdated snapd (2.61) on build infrastructure unable to install core20 base. Issue is 556 days old with no maintainer response. | |
| #1892551 snapcraft fails to run if it is installed as a try snap | snapcraft (launchpad) | open | Snapcraft 4.x fails when installed via 'snap try': the LXD build provider tries to download the host snapcraft snap file from snapd, which returns 400 for try snaps. Unlabelled, 0 comments, ~6 years old, never triaged. | |
| #1978844 snapcraft try not available for core22-based snap | snapcraft (launchpad) | closed | Closed without resolution or comments. The snapcraft try command remains unavailable for core22-based snaps, with attempts failing or falling back to legacy implementations. | |
| #2028686 snapcraft pack failure from git worktree | snapcraft (launchpad) | open | snapcraft pack fails when building from a git worktree. Issue is 1136 days old with no labels, no comments, and no maintainer engagement. | |
| #1867052 Snapcraft crashes while creating snap for ssh-audit | snapcraft (launchpad) | closed | Snapcraft v2.43.1 crashes with FileNotFoundError during snap packaging due to a missing executable path in snapcraft.yaml. Issue is completely inactive for over 6 years. | |
| #2104274 Snapcraft has unclear behavior when providing same build-snap from different channels | snapcraft (launchpad) | open | Bug report: snapcraft resolves build-snap from wrong channel (stable vs candidate). Untriaged, no maintainer response in 527 days. | |
| #1992557 snapcraft remote-build snapcraft.yaml validation too strict | snapcraft (launchpad) | open | snapcraft remote-build validation rejects empty LD_LIBRARY_PATH in environment, blocking some classic snaps. Issue is 4 years old with no maintainer engagement. | |
| #2098999 Snapcraft auth does not create dir needed and errors out | snapcraft (launchpad) | open | Snapcraft auth fails to create credentials directory on macOS, causing FileNotFoundError. Issue is 560 days old with no maintainer response. |