Hello,
I am building a snap that has a dependency on git
. Git as we may all know exists in the main repos.
When I run snapcraft --use-lxd --debug
to build the snap, I get the error posted below. While in the debug container if I run apt search git
, git does show up in the container. And is also already installed due to a dependency for the go plugin. This implies that 1) the package exists, and 2) there is connectivity in the container. (Plus my additional ping test below).
Any ideas?
Thank you!
Snapcraft Versions
In the debug container…
# snapcraft --version
snapcraft, version 3.11
On my host system…
❯ snapcraft --version
snapcraft, version 4.0.2
Error
Failed to fetch stage packages: Error downloading packages for part 'fac': The package 'git' was not found..
snapcraft.yaml
name: fac
base: core18
version: "2.0.0"
# https://github.com/snapcore/snapd/blob/master/spdx/licenses.go
license: "MIT"
summary: Easy-to-use CUI for fixing git conflicts
description: |
Fac is an easy-to-use CUI for fixing git conflicts written in Go.
grade: stable
confinement: strict
architectures:
- build-on: amd64
plugs:
dot-fac-yml:
interface: personal-files
read:
- $HOME/.fac.yml
dot-gitconfig:
interface: personal-files
read: [$HOME/.gitconfig]
apps:
fac:
command: bin/fac
plugs:
- network
- home
- dot-fac-yml
- dot-gitconfig
parts:
# go:
# source-tag: go1.10.1
fac:
plugin: go
# after: [go]
source: https://github.com/mkchoi212/fac.git
source-type: git
go-importpath: github.com/mkchoi212/fac
stage-packages:
- git
Other tests
Connectivity from the container
# ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8): 56 data bytes
64 bytes from 8.8.8.8: icmp_seq=0 ttl=55 time=8.353 ms
64 bytes from 8.8.8.8: icmp_seq=1 ttl=55 time=7.365 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=55 time=7.121 ms
I just attempted to build in the default multipass VM (same YAML) and things to note…
- multipass installs snapcraft 4.x (lxd seems to use 3.x)
- git was successfully installed as part of the build staging (required by go)
- Then fails with a completely new error
Error
exec: "gcc": executable file not found in $PATH
I am assuming that the behaviour and difference in issues are due to the different snapcraft versions.
OK, so I added a build package for gcc. Then multipass fails with:
Error
Building fac
go build github.com/mkchoi212/fac
# runtime/cgo
_cgo_export.c:3:10: fatal error: stdlib.h: No such file or directory
#include <stdlib.h>
^~~~~~~~~~
compilation terminated.
Failed to run 'go build github.com/mkchoi212/fac' for 'fac': Exited with code 2.
Verify that the part is using the correct parameters and try again.
I also had a disk full issue, so after fixing that I tried using lxd again, but the original error persists.
You’re missing the build-packages:
of libc6-dev
, which provides the stdlib.h
header file.
But should we be needing to stage that when it is a dependency of a plug in? Should it not just happen? Especially when you never had to on older versions of snapcraft (< 4.x)
It also seems funny that lxd and multipass use different versions of snapcraft (but assume that is transitional).
![:man_shrugging: :man_shrugging:](https://forum.snapcraft.io/images/emoji/twitter/man_shrugging.png?v=12)
I’ll stage that package and see where i get though.
Thanks for the tip.
Ok, thanks to @lucyllewy, I can successfully build in multipass/snapcraft 4 (not in lxd/snapcraft 3)
But I am curious as to:
- why lxd/multipass use different versions of snapcraft; and
- why the go plugin requires these extra build deps on snapcraft 4 (vs 3)
- And why the git stage fails under v3
Curious is all, appreciate any replies.
Dustin Krysak via snapcraft.io forum@forum.snapcraft.io writes:
Hello,
I am building a snap that has a dependency on git
. Git as we may all know exists in the main repos.
When I run snapcraft --use-lxd --debug
to build the snap, I get the error posted below. While in the debug container if I run apt search git
, git does show up in the container. This implies that 1) the package exists, and 2) there is connectivity in the container. (Plus my additional ping test below).
Any ideas?
Thank you!
Snapcraft Versions
In the debug container…
# snapcraft --version
snapcraft, version 3.11
On my host system…
❯ snapcraft --version
snapcraft, version 4.0.2
This is an unfortunate bug we have to solve. If you snapcraft clean --use-lxd and start fresh, things should go back to normal.
Details are that We cannot disable snap refreshes so the container updates out of band from what is on your host. We do not inject Snapcraft on every run to keep things optimal.
1 Like
Thanks for that! Few observations after running snapcraft clean
and snapcraft clean --use-lxd
:
- LXD now has snapcraft v4
- Git is found for staging
- I can now build in LXD if I remove the
gcc
and libc6-dev
build packages
- If I remove the build packages, it no longer builds in multipass
Is there some reason they are needed in multipass but not in LXD?
Its odd that the go behaviour is different between LXD and multipass.