Github builds fail to find command file. Local builds works

Hello,

when I run snapcraft locally, the builds work without issues and the prime directory contains the executable file as indicated in the apps/command section.

However, the automated build process from the store throws errors:

scons: Building targets ...
...
Install file: "bin/sar2" as "/root/parts/sar2/install/usr/bin/sar2"
Staging sar2 
Priming alsa-mixin 
Priming sar2 
Failed to generate snap metadata: Specified command 'usr/bin/sar2' was not found.
Verify the command is correct and for a more deterministic outcome, specify the relative path to the command from the prime directory.
Build failed
...

I can do very little to figure this out, since things work locally (after clean and everything) and for all I can see things are correctly setup on my side. What is different on this builds?

@hsanjuan They shouldn’t be different, though the store uses the “stable” channel for snapcraft (in case you’re not locally).

Can you share the full log and/or project?

Project:

Full log: https://launchpadlibrarian.net/477644335

I also use stable snapcraft locally. The only difference in logs is that mine priming phase works and this one not. It seems that the build process uses lxd? Can that be the issue?

I built locally with lxd instead and things work without issue :confused:

There must be a filesystem sync issue or something.

I made some changes and I got a working build batch now. This is weird because it always worked locally and afaik I did not really touch the install location but well. Hopefully it stays working.

I have a similar problem - my build works locally using both the multipass and lxd backends, but fails on Launchpad with a similar error to yours.

snapcraft.yaml: https://github.com/juju-solutions/etcd-snaps/blob/v3.4/snap/snapcraft.yaml

Launchpad build log: https://launchpadlibrarian.net/477678410/buildlog_snap_ubuntu_bionic_amd64_etcd-3.4_BUILDING.txt.gz

Building etcd-wrapper 
Staging etcd 
Staging etcd-wrapper 
Priming etcd 
Priming etcd-wrapper 
Failed to generate snap metadata: Specified command 'etcdctl' was not found.
Verify the command is correct and for a more deterministic outcome, specify the relative path to the command from the prime directory.
Build failed
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/lpbuildd/target/build_snap.py", line 258, in run
    self.build()
  File "/usr/lib/python2.7/dist-packages/lpbuildd/target/build_snap.py", line 247, in build
    env=env)
  File "/usr/lib/python2.7/dist-packages/lpbuildd/target/build_snap.py", line 100, in run_build_command
    return self.backend.run(args, env=full_env, **kwargs)
  File "/usr/lib/python2.7/dist-packages/lpbuildd/target/lxd.py", line 537, in run
    subprocess.check_call(cmd, **kwargs)
  File "/usr/lib/python2.7/subprocess.py", line 541, in check_call
    raise CalledProcessError(retcode, cmd)
CalledProcessError: Command '['lxc', 'exec', 'lp-bionic-amd64', '--env', 'LANG=C.UTF-8', '--env', 'SHELL=/bin/sh', '--env', 'SNAPCRAFT_BUILD_INFO=1', '--env', 'SNAPCRAFT_IMAGE_INFO={"build-request-id": "lp-56223100", "build-request-timestamp": "2020-04-30T15:36:13Z", "build_url": "https://launchpad.net/~cdk8s/+snap/etcd-3.4/+build/933402"}', '--env', 'SNAPCRAFT_BUILD_ENVIRONMENT=host', '--env', 'http_proxy=http://10.10.10.1:8222/', '--env', 'https_proxy=http://10.10.10.1:8222/', '--env', 'GIT_PROXY_COMMAND=/usr/local/bin/snap-git-proxy', '--', '/bin/sh', '-c', 'cd /build/etcd && linux64 snapcraft']' returned non-zero exit status 2

@hsanjuan you said you made some changes and got it working. I’d be curious to know what those changes were, if you remember.

The scons plugins I use sets an env variable “DESTDIR” that points to the install folder… Rather than me hardcoding /root/parts/sar2/install, I changed my build script to be able to use DESTDIR directly.

Now, I think that DESTDIR is just set to /root/parts/sar2/install anyways so this would have effectively changed nothing (??). Local build always worked, but somehow, after committing and pushing this change, the Github build worked. I still think something is funky on those build containers…

Maybe DESTDIR is different in that build system…

@hsanjuan Yes, you correctly fixed it to use prefix=/usr. The /root/parts/.... path is specific to your local build-environment.

1 Like

Aha! That’s a clue for me, thank you. I probably need to update these lines: https://github.com/juju-solutions/etcd-snaps/blob/v3.4/snap/snapcraft.yaml#L28

2 Likes

Similarly @tvansteenburgh, You are also doing the same thing with root/parts/etcd/install/bin/etcd.

Use $SNAPCRAFT_PART_INSTALL instead of '/root/parts/etcd/install`

2 Likes

This happened to me before. I had to replace some directories with environment variables that were documented in Snapcraft’s documentation.

Worked like a charm once that’s done.