Issues with go plugin - GIT missing

Hi there,

I am just updating some of my snap packages to use V3.0/multipass.

# snapcraft --version
snapcraft, version 3.1

I’m getting the following error:

exec: "git": executable file not found in $PATH
go: missing Git command. See https://golang.org/s/gogetcmd

Now assuming this is in the multipass VM, I can stage the binary. But - if this is required for the plugin to work, should that not already be populated in there? Or am I hitting something else?

Simple snapcraft.yaml right now:

name: lxdev # you probably want to 'snapcraft register <name>'
base: core18 # the base snap is the execution environment for this snap
version: '0.0.4' # just for humans, typically '1.2+git' or '1.3.2'
summary: Quick dev environments for linux using LXD.  # 79 char long summary
description: |
  Quick dev environments for linux using LXD.
  Disposable, composable, simple.

grade: devel # must be 'stable' to release into candidate/stable channels
confinement: devmode # use 'strict' once you have the right plugs and slots

parts:
  lxdev:
    source: .
    # See 'snapcraft plugins'
    plugin: go
    go-importpath: github.com/bketelsen/lxdev

apps:
  lxdev:
    command: lxdev

Full --debug from the build:

snapcraft --debug
Launching a VM.
Pulling lxdev
go get -t -d ./github.com/bketelsen/lxdev/...
go: missing Git command. See https://golang.org/s/gogetcmd
package github.com/bketelsen/libgo/events: exec: "git": executable file not found in $PATH
go: missing Git command. See https://golang.org/s/gogetcmd
package github.com/buger/goterm: exec: "git": executable file not found in $PATH
go: missing Git command. See https://golang.org/s/gogetcmd
package github.com/lxc/lxd/client: exec: "git": executable file not found in $PATH
package github.com/lxc/lxd/shared/api: cannot find package "github.com/lxc/lxd/shared/api" in any of:
        /snap/go/3129/src/github.com/lxc/lxd/shared/api (from $GOROOT)
        /root/parts/lxdev/go/src/github.com/lxc/lxd/shared/api (from $GOPATH)
package github.com/lxc/lxd/shared/i18n: cannot find package "github.com/lxc/lxd/shared/i18n" in any of:
        /snap/go/3129/src/github.com/lxc/lxd/shared/i18n (from $GOROOT)
        /root/parts/lxdev/go/src/github.com/lxc/lxd/shared/i18n (from $GOPATH)
package github.com/lxc/lxd/shared/termios: cannot find package "github.com/lxc/lxd/shared/termios" in any of:
        /snap/go/3129/src/github.com/lxc/lxd/shared/termios (from $GOROOT)
        /root/parts/lxdev/go/src/github.com/lxc/lxd/shared/termios (from $GOPATH)
go: missing Git command. See https://golang.org/s/gogetcmd
package github.com/mitchellh/go-homedir: exec: "git": executable file not found in $PATH
go: missing Git command. See https://golang.org/s/gogetcmd
package github.com/pkg/errors: exec: "git": executable file not found in $PATH
go: missing Git command. See https://golang.org/s/gogetcmd
package github.com/gobuffalo/packr/v2: exec: "git": executable file not found in $PATH
package github.com/gobuffalo/packr/v2/file/resolver: cannot find package "github.com/gobuffalo/packr/v2/file/resolver" in any of:
        /snap/go/3129/src/github.com/gobuffalo/packr/v2/file/resolver (from $GOROOT)
        /root/parts/lxdev/go/src/github.com/gobuffalo/packr/v2/file/resolver (from $GOPATH)
go: missing Git command. See https://golang.org/s/gogetcmd
package github.com/dixonwille/wlog: exec: "git": executable file not found in $PATH
go: missing Git command. See https://golang.org/s/gogetcmd
package github.com/olekukonko/tablewriter: exec: "git": executable file not found in $PATH
go: missing Git command. See https://golang.org/s/gogetcmd
package github.com/spf13/cobra: exec: "git": executable file not found in $PATH
go: missing Git command. See https://golang.org/s/gogetcmd
package github.com/spf13/viper: exec: "git": executable file not found in $PATH
go: missing Git command. See https://golang.org/s/gogetcmd
package gopkg.in/yaml.v2: exec: "git": executable file not found in $PATH
Failed to run 'go get -t -d ./github.com/bketelsen/lxdev/...' for 'lxdev': Exited with code 1.
Verify that the part is using the correct parameters and try again.

I’m likely missing something stupid.

Thank you.

NOTE - if I install gcc and git in the container - all builds ok.

so add them as build-packages: to your part :wink:

2 Likes

Indeed. I covered this on the live stream last night :wink:

https://www.youtube.com/watch?v=BEp_l2oUcD8&

1 Like

@bashfulrobot mind adding this as an answer? :slight_smile:

Hi All,

I guess how I “should” have phrased this is…

If those are dependencies of using the go plugin, should they maybe just be automatically be added as build dependencies? Or at a minimum be added to the docs? I can fire over a PR to add that to the docs though. :slight_smile:

EDIT - reading the doc guidelines.

@popey - It is literally sitting in an open tab for later. Just never got to it. :+1:

1 Like

I honestly don’t know if git is needed by the go plugin or if it’s just needed by the project you happen to be building?

go get will try to use the appropriate tool to fetch the source and its dependencies. If the project is really standalone, it doesn’t need anything more. If it needs to get something from github or gitlab it’ll need git, if it needs something from launchpad it’ll need bzr, etc etc. That’s why the packaged go has

Recommends: g++, gcc, golang-1.6-race-detector-runtime, libc6-dev, pkg-config
Suggests: bzr, ca-certificates, git, mercurial, subversion

note if all these were pulled in by the go plugin, things might go smoother. OTOH you’d pull them even if you didn’t need to…

1 Like

I’ll test with a few more to try and confirm.