Can't install Snapcraft

I’ve been following https://blog.ubuntu.com/2017/06/28/build-test-and-publish-snap-packages-using-snapcraft and https://circleci.com/docs/2.0/build-publish-snap-packages/ including some cross solutions but have not been able to make it work.

tried to ssh in but apart from realising that I am root and do not require the “sudo”, I have managed to apt install docker and snapd, but have been unable to launch “snap” for the installation of snapcraft, and also any possible docker commands

Edit: Included errors ourput from my job:

/bin/bash: snapcraft: command not found
Exited with code 127

Error output from SSH:

root@365c6f:~ apt install snapd
Reading package lists... Done
Building dependency tree       
Reading state information... Done
snapd is already the newest version (2.21-2+b1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

root@365c:6f~  snap install snapcraft
2018/08/30 12:47:29.86 main.go:220: WARNING: cannot create syslog logger
error: cannot communicate with server: Post http://localhost/v2/snaps/snapcraft: dial unix /run/snapd-snap.socket: connect: no such file or directory
version: 2
    jobs:
      build:
        machine: true
        working_directory: ~/project
        steps:
          - checkout
          - run:
              command: |
                sudo apt update && sudo apt install -y snapd
                docker run -v $(pwd):$(pwd) -t ubuntu:xenial sh -c "apt update -qq && apt install snapcraft -y && cd $(pwd) && snapcraft"

This is taken from the circleci blog. https://circleci.com/blog/build-test-publish-snap-packages/

Sorry. Forgot about that. Would you have any advice for me?

#!/bin/bash -eo pipefail
snapcraft

/bin/bash: snapcraft: command not found
Exited with code 127

We’re getting there! (Friendly tip: errors and log files should be in the first post).

Is the binary snapcraft a different installation to the snapd? I wonder if it’s worth SSHing into the server and using apt-cache search for a bit to see what other things are available for install.

Thanks for the tip! Have updated my original post with error output.

The edit is fine, but I perhaps could have been clearer with my point. I mean that errors are the most important thing readers need to know, and they should be put in the first post when you make the first post, rather than adding it in post 7 after several rounds of questions :smile_cat:

Don’t worry about it too much though - learning how to ask questions is a learning curve in itself!

Thanks!!
I have tried a clean docker instance on my laptop to build the snap based on the instructions from my original post, it works. I tried SSH-ing in again after that. The issue I am facing with the instance in CircleCI is that I dont have a docker executable after “apt install docker”.

root@afe37d4bda:~# find /usr -name "*dock*"
/usr/bin/wmdocker
/usr/share/menu/docker
/usr/share/doc/docker
/usr/share/man/man1/wmdocker.1.gz

On Ubuntu, the native package is called docker.io. However, if you add the official Docker Apt repo to your system, it’s called docker-ce.

apt-cache says that docker is a:

System tray for KDE3/GNOME2 docklet applications

which is nothing to do with containerisation.

Turns out, CircleCI wasnt getting my latest commits. Not sure why. So I redid the setup and with the instructions from the same blog post, I got more things working. I run into this error now after the priming stage.

Sorry, Snapcraft ran into an error when trying to running through its lifecycle that generated a trace that has been put in '/tmp/tmpnuapz_10/trace.txt'.

Right. To help you progress, would you explain here, in your own words, what the error message is asking you to do?

To head to /tmp/tmpnuapz_10/trace.txt and look through the logs. But I cant find it.

Right, indeed. I would make these guesses:

  • You need an SSH session in CircleCI to examine this log file
  • Snapcraft is running its own Docker inside your Docker container, and you need to look into that (exited) container to find the log file

I wonder if it is worth trying to get Snapcraft working on your local machine first, to get an understanding of how it works. I haven’t used it, but I wonder if it is not a trivial undertaking, and is going to be a a bit of a battle if you are new to CI or Linux.

You could try a few more things in your CircleCI machine via SSH, but this eats build minutes, which is worth bearing in mind if you are on the free tier.

Yea, the snapcraft runs well on my local machine, which led me to thinking it was my circleci configuration. But now, maybe it’s a snapcraft issue. I’ll head over to the snapcraft forums to see if someone could help.

I’ll heed your advice and run it in a Docker or LXC first before going anywhere else. Thanks alot for your help!

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.