Snapcraft --use-lxd no longer works on TravisCI?

This is possibly a TravisCI issue but I’ll raise it here because many of the Snapcrafter projects have travis.yml files and they no longer work because of this possible bug.

It looks like the permissions or groups changed on the TravisCI boxes because, since you can’t run lxd with sudo anymore, the travis user can’t access the LXD socket.

I ran into the same issue while debugging via ssh on a CircleCI box as well, which leads me to believe this might be a Snapcraft or LXD issue since it affects two different platforms.

1 Like

I had a similar issue a while ago. In my case I changed the permissions of the lxd sock file. Can you also check if that helps you as well ?

sudo chown $USER:$USER /var/snap/lxd/common/lxd/unix.socket

Yeah, sorry about this. We discovered this on Friday. Give this a bash.

In case that changes, here it is:

language: bash
dist: bionic

env:
  global:
    - LC_ALL: C.UTF-8
    - LANG: C.UTF-8
    - SNAPCRAFT_ENABLE_SILENT_REPORT: y
    - PATH: /snap/bin:$PATH

addons:
  snaps:
    - name: snapcraft
      channel: stable
      classic: true
    - name: http
    - name: lxd
      channel: stable

install:
  - sudo apt autoremove --yes --purge lxd lxd-client
  - sudo /snap/bin/lxd init --auto
  - sudo /snap/bin/lxd waitready
script:
  # Workaround until https://github.com/snapcore/snapcraft/pull/3240 is released.
  - sudo bash -c "unset SUDO_USER && snapcraft --use-lxd"
after_failure:
  - http https://api.snapcraft.io/v2/snaps/info/core architecture==amd64 Snap-Device-Series:16
1 Like

A PR to address this in snapcraft: https://github.com/snapcore/snapcraft/pull/3240

You can try the fix by setting the snapcraft channel to edge/pr-3240

Fantastic, this seemed to work! Thanks a ton!

To be clear, this isn’t the final fix, correct? We’re waiting for the PR and then we won’t need that sudo shim?

Yes. The PR now changes the error to a warning and you should be back in business without the workaround…

1 Like