Snapcraft crashes after defining a local source for a golang project

Bug #1515132 reported by XiaoGuo, Liu
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Snapcraft
Fix Released
High
Sergio Schvezov

Bug Description

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.

description: updated
Revision history for this message
Leo Arias (elopio) wrote :

I think this is a valid use case, so removing the dup.

lets say you have a go project in a local dir, you don't want to go get it . Or, lets say you put your snapcraft.yaml in github, in the same repo as your go code, so github clone already downloaded the code, you don't want go get to bring it too. And maybe you cloned and checked out a branch, not master...

Revision history for this message
Sergio Schvezov (sergiusens) wrote :
Changed in snapcraft:
status: New → Fix Committed
assignee: nobody → Sergio Schvezov (sergiusens)
importance: Undecided → High
Changed in snapcraft:
milestone: none → 0.5
Revision history for this message
XiaoGuo, Liu (liu-xiao-guo) wrote :

Thanks, it works in the 0.5 version!

Revision history for this message
Leo Arias (elopio) wrote :

Fixed in https://github.com/ubuntu-core/snapcraft/pull/97
I followed liux' instructions and confirm that the snap can be created with the local source.

Changed in snapcraft:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.