Snapcraft crashes after defining a local source for a golang project
Metadata
Current evaluation
Snapcraft's Go plugin crashed on local source paths because it assumed a URI. Fixed by ubuntu-core/snapcraft#97 (commit f15caeeb1) and confirmed working in 0.5.
Resolution: closed resolved
Reason: PR ubuntu-core/snapcraft#97 added support for local Go sources in commit f15caeeb1. The reporter confirmed the fix worked in Snapcraft 0.5, and the maintainer verified that the snap built successfully.
Evaluated by: mr-cal-bot
No scores available.
Issue body
I have a simple snappy project at
https://github.com/liu-xiao-guo/go-webserver
If I do not want to use "source: git://github.com/liu-xiao-guo/golang-http" in the snapcraft.yaml to compile the go. Instead, I want to make the source code locally. Then I make the following change to my snapcraft.yaml:
name: go-webserver
vendor: XiaoGuo, Liu <email address hidden>
icon: go.png
version: 1.0.7
summary: Go webserver
description: This is a simple go webserver. It is a service
services:
webserver:
description: "Go websever"
start: bin/golang-http
caps:
- network-client
- network-service
parts:
webserver:
plugin: go
source: ./src/golang-http
Inside the golang-http, it has only one file named "main.go", which can be found at:
https://github.com/liu-xiao-guo/golang-http/blob/master/main.go
liuxg@liuxg:~/snappy/examples/go-webserver1$ snapcraft
Traceback (most recent call last):
File "/usr/bin/snapcraft", line 33, in <module>
snapcraft.main.main()
File "/usr/lib/python3/dist-packages/snapcraft/main.py", line 147, in main
args.func(args)
File "/usr/lib/python3/dist-packages/snapcraft/cmds.py", line 103, in assemble
snap(args)
File "/usr/lib/python3/dist-packages/snapcraft/cmds.py", line 85, in snap
cmd(args)
File "/usr/lib/python3/dist-packages/snapcraft/cmds.py", line 322, in cmd
config = _load_config()
File "/usr/lib/python3/dist-packages/snapcraft/cmds.py", line 387, in _load_config
_config = snapcraft.yaml.Config()
File "/usr/lib/python3/dist-packages/snapcraft/yaml.py", line 139, in __init__
self.load_plugin(part_name, plugin_name, properties)
File "/usr/lib/python3/dist-packages/snapcraft/yaml.py", line 192, in load_plugin
part_name, plugin_name, properties)
File "/usr/lib/python3/dist-packages/snapcraft/lifecycle.py", line 274, in load_plugin
return PluginHandler(plugin_name, part_name, properties)
File "/usr/lib/python3/dist-packages/snapcraft/lifecycle.py", line 65, in __init__
self._load_code(plugin_name, properties)
File "/usr/lib/python3/dist-packages/snapcraft/lifecycle.py", line 92, in _load_code
self.code = plugin(self.name, options)
File "/usr/lib/python3/dist-packages/snapcraft/plugins/go.py", line 56, in __init__
self.fullname = self.options.source.split("://")[1]
IndexError: list index out of range
liuxg@liuxg:~$ snapcraft version
snapcraft (0.4).
Run "snapcraft help" to get started.
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| stealth/space-bunny-alpha | — | closed resolved | Snapcraft's Go plugin crashed on local source paths because it assumed a URI. Fixed by ubuntu-core/snapcraft#97 (commit f15caeeb1) and confirmed working in 0.5. | |
| stealth/space-bunny-alpha | — | closed resolved | Go plugin crashed with IndexError when a part used a local `source:` path (no scheme). Fixed by PR #97 (commit f15caeeb1, merge 7e6dc4b74), which added local-source support to the Go plugin; reporter confirmed it worked in snapcraft 0.5. | |
| stealth/space-bunny-alpha | — | closed resolved | Fixed by merged PR #97 (7e6dc4b74), adding local-source support and safer source parsing to the Go plugin. | |
| qwen/qwen3.6-35b-a3b | — | — | Closed as fixed. The Go plugin was updated to handle local source paths, resolving the IndexError crash when the source field lacks a protocol. | |
| qwen/qwen3.6-35b-a3b | — | — | Closed. The Go plugin crash on local source paths was fixed by updating the source parsing logic to handle non-URL strings, preventing the IndexError during configuration loading. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Closed. The IndexError crash when using local source paths in the Go plugin was fixed in later snapcraft versions after the hardcoded URL parsing logic was updated. |
Update history
| Date | Change |
|---|---|
| created |
Related work
-
Likely Fixed By:
ubuntu-core/snapcraft#97
(confidence 100%)
The linked PR fixed local-source handling in the Go plugin; commit f15caeeb1 is titled "go plugin: Support local sources".
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #1516228 missing " git://" in the source crashes the snapcraft | snapcraft (launchpad) | closed | Fixed in Snapcraft 0.5/master: a bare GitHub source no longer crashes and now reports "local source is not a directory" through pull-step handling (PR #448). | |
| #1499240 User friendly error missing when using go's source entry incorrectly | snapcraft (launchpad) | closed | Tracked to GitHub canonical/snapcraft#20 and closed by PR #97 (merge 7e6dc4b74, commit f15caeeb1), which added local-source support to the go plugin in snapcraft 0.5; maintainers noted the plugin now handles source-type projects differently. | |
| #1590108 Go plugin breaks with snapcraft.yaml in tree | snapcraft (launchpad) | closed | Fixed by hard-linking local sources instead of symlinking them, preventing recursive GOPATH traversal; merged in snapcore/snapcraft#622 (commit a07fa0faa). | |
| #4285 Snapcraft v7 fails to build core18 snap with local plugins | snapcraft | closed | Snapcraft 7 broke core18 snaps with local plugins (module 'snapcraft' has no attribute 'sources'). Fixed by merged PR #4337 (commit 15011660a) exporting sources to legacy plugins; reporter confirmed success on 7.5.3. | |
| #21 snapcraft throws FileExistsError: with very simple Python snap | snapcraft | closed | Replaced the FileExistsError with local-source validation in 0e575ce53; corrected local-source handling merged via PR #377 (8b4a18d9b). |