Snapcraft build on Ubuntu 20.04 has network errors

I had a build of an app work on Ubuntu 18.04 and am trying to get it working on Ubuntu 20.04. I am having many issues. Currently I think it is network related. I am building with --use-lxd. Every time I run the snapcraft command it circles through the following 3 errors:

  1. [Errno 6] No such device or address: '/run/snapd-snap.socket’
  2. [Errno 6] No such device or address: '/run/snapd.socket’
  3. /run/initctl is a named pipe

I see one of those 3 errors after:

  • snapcraftctl pull

I have tried doing things like: “sudo service snapd start” and “sudo systemctl start snapd.service” but to no success (Local and in the lxc container, but I think the lxc container state gets lost anyway when it closes). Also the setup is weird because with lxd snapcraft is building in a lxc container. I am unsure exactly how it is separated and what control there is outside the container. I am unsure how to tackle this, the internet does not have much.

Any ideas?

Hi @orileibovici,

Can you post the full logs? Thanks!

Yes! @mr_cal Here:

Error 1:

Traceback (most recent call last):
  File "/snap/snapcraft/7201/lib/python3.8/site-packages/snapcraft/file_utils.py", line 102, in link_or_copy
    link(source, destination, follow_symlinks=follow_symlinks)
  File "/snap/snapcraft/7201/lib/python3.8/site-packages/snapcraft/file_utils.py", line 136, in link
    os.link(source_path, destination, follow_symlinks=False)
OSError: [Errno 18] Invalid cross-device link: '/run/snapd-snap.socket' -> '/root/parts/name_of_app/src/run/snapd-snap.socket'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/snap/snapcraft/7201/bin/snapcraft", line 8, in <module>
    sys.exit(run())
  File "/snap/snapcraft/7201/lib/python3.8/site-packages/click/core.py", line 1137, in __call__
    return self.main(*args, **kwargs)
  File "/snap/snapcraft/7201/lib/python3.8/site-packages/click/core.py", line 1062, in main
    rv = self.invoke(ctx)
  File "/snap/snapcraft/7201/lib/python3.8/site-packages/click/core.py", line 1668, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/snap/snapcraft/7201/lib/python3.8/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/snap/snapcraft/7201/lib/python3.8/site-packages/click/core.py", line 763, in invoke
    return __callback(*args, **kwargs)
  File "/snap/snapcraft/7201/lib/python3.8/site-packages/snapcraft/cli/lifecycle.py", line 387, in snap
    _execute(steps.PRIME, parts=tuple(), pack_project=True, output=output, **kwargs)
  File "/snap/snapcraft/7201/lib/python3.8/site-packages/snapcraft/cli/lifecycle.py", line 102, in _execute
    lifecycle.execute(step, project_config, parts)
  File "/snap/snapcraft/7201/lib/python3.8/site-packages/snapcraft/internal/lifecycle/_runner.py", line 145, in execute
    executor.run(step, part_names)
  File "/snap/snapcraft/7201/lib/python3.8/site-packages/snapcraft/internal/lifecycle/_runner.py", line 199, in run
    self._handle_step(part_names, part, step, current_step, cli_config)
  File "/snap/snapcraft/7201/lib/python3.8/site-packages/snapcraft/internal/lifecycle/_runner.py", line 213, in _handle_step
    getattr(self, "_run_{}".format(current_step.name))(part)
  File "/snap/snapcraft/7201/lib/python3.8/site-packages/snapcraft/internal/lifecycle/_runner.py", line 255, in _run_pull
    self._run_step(step=steps.PULL, part=part, progress="Pulling")
  File "/snap/snapcraft/7201/lib/python3.8/site-packages/snapcraft/internal/lifecycle/_runner.py", line 356, in _run_step
    getattr(part, step.name)()
  File "/snap/snapcraft/7201/lib/python3.8/site-packages/snapcraft/internal/pluginhandler/__init__.py", line 491, in pull
    self._do_runner_step(steps.PULL)
  File "/snap/snapcraft/7201/lib/python3.8/site-packages/snapcraft/internal/pluginhandler/__init__.py", line 281, in _do_runner_step
    return getattr(self._runner, "{}".format(step.name))()
  File "/snap/snapcraft/7201/lib/python3.8/site-packages/snapcraft/internal/pluginhandler/_runner.py", line 81, in pull
    self._run_scriptlet(
  File "/snap/snapcraft/7201/lib/python3.8/site-packages/snapcraft/internal/pluginhandler/_runner.py", line 189, in _run_scriptlet
    raise error
  File "/snap/snapcraft/7201/lib/python3.8/site-packages/snapcraft/internal/pluginhandler/_runner.py", line 178, in _run_scriptlet
    self._handle_builtin_function(
  File "/snap/snapcraft/7201/lib/python3.8/site-packages/snapcraft/internal/pluginhandler/_runner.py", line 233, in _handle_builtin_function
    function(**function_args)
  File "/snap/snapcraft/7201/lib/python3.8/site-packages/snapcraft/internal/pluginhandler/__init__.py", line 511, in _do_pull
    self.source_handler.pull()
  File "/snap/snapcraft/7201/lib/python3.8/site-packages/snapcraft/internal/sources/_local.py", line 37, in pull
    file_utils.link_or_copy_tree(
  File "/snap/snapcraft/7201/lib/python3.8/site-packages/snapcraft/file_utils.py", line 245, in link_or_copy_tree
    copy_function(source, destination)
  File "/snap/snapcraft/7201/lib/python3.8/site-packages/snapcraft/file_utils.py", line 110, in link_or_copy
    copy(source, destination, follow_symlinks=follow_symlinks)
  File "/snap/snapcraft/7201/lib/python3.8/site-packages/snapcraft/file_utils.py", line 159, in copy
    shutil.copy2(source, destination, follow_symlinks=follow_symlinks)
  File "/snap/snapcraft/7201/usr/lib/python3.8/shutil.py", line 435, in copy2
    copyfile(src, dst, follow_symlinks=follow_symlinks)
  File "/snap/snapcraft/7201/usr/lib/python3.8/shutil.py", line 264, in copyfile
    with open(src, 'rb') as fsrc, open(dst, 'wb') as fdst:
OSError: [Errno 6] No such device or address: '/run/snapd-snap.socket'

Error 2:

Traceback (most recent call last):
      File "/snap/snapcraft/7201/lib/python3.8/site-packages/snapcraft/file_utils.py", line 102, in link_or_copy
        link(source, destination, follow_symlinks=follow_symlinks)
      File "/snap/snapcraft/7201/lib/python3.8/site-packages/snapcraft/file_utils.py", line 136, in link
        os.link(source_path, destination, follow_symlinks=False)
    OSError: [Errno 18] Invalid cross-device link: '/run/snapd.socket' -> '/root/parts/name_of_app/src/run/snapd.socket'

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "/snap/snapcraft/7201/bin/snapcraft", line 8, in <module>
        sys.exit(run())
      File "/snap/snapcraft/7201/lib/python3.8/site-packages/click/core.py", line 1137, in __call__
        return self.main(*args, **kwargs)
      File "/snap/snapcraft/7201/lib/python3.8/site-packages/click/core.py", line 1062, in main
        rv = self.invoke(ctx)
      File "/snap/snapcraft/7201/lib/python3.8/site-packages/click/core.py", line 1668, in invoke
        return _process_result(sub_ctx.command.invoke(sub_ctx))
      File "/snap/snapcraft/7201/lib/python3.8/site-packages/click/core.py", line 1404, in invoke
        return ctx.invoke(self.callback, **ctx.params)
      File "/snap/snapcraft/7201/lib/python3.8/site-packages/click/core.py", line 763, in invoke
        return __callback(*args, **kwargs)
      File "/snap/snapcraft/7201/lib/python3.8/site-packages/snapcraft/cli/lifecycle.py", line 387, in snap
        _execute(steps.PRIME, parts=tuple(), pack_project=True, output=output, **kwargs)
      File "/snap/snapcraft/7201/lib/python3.8/site-packages/snapcraft/cli/lifecycle.py", line 102, in _execute
        lifecycle.execute(step, project_config, parts)
      File "/snap/snapcraft/7201/lib/python3.8/site-packages/snapcraft/internal/lifecycle/_runner.py", line 145, in execute
        executor.run(step, part_names)
      File "/snap/snapcraft/7201/lib/python3.8/site-packages/snapcraft/internal/lifecycle/_runner.py", line 199, in run
        self._handle_step(part_names, part, step, current_step, cli_config)
      File "/snap/snapcraft/7201/lib/python3.8/site-packages/snapcraft/internal/lifecycle/_runner.py", line 213, in _handle_step
        getattr(self, "_run_{}".format(current_step.name))(part)
      File "/snap/snapcraft/7201/lib/python3.8/site-packages/snapcraft/internal/lifecycle/_runner.py", line 255, in _run_pull
        self._run_step(step=steps.PULL, part=part, progress="Pulling")
      File "/snap/snapcraft/7201/lib/python3.8/site-packages/snapcraft/internal/lifecycle/_runner.py", line 356, in _run_step
        getattr(part, step.name)()
      File "/snap/snapcraft/7201/lib/python3.8/site-packages/snapcraft/internal/pluginhandler/__init__.py", line 491, in pull
        self._do_runner_step(steps.PULL)
      File "/snap/snapcraft/7201/lib/python3.8/site-packages/snapcraft/internal/pluginhandler/__init__.py", line 281, in _do_runner_step
        return getattr(self._runner, "{}".format(step.name))()
      File "/snap/snapcraft/7201/lib/python3.8/site-packages/snapcraft/internal/pluginhandler/_runner.py", line 81, in pull
        self._run_scriptlet(
      File "/snap/snapcraft/7201/lib/python3.8/site-packages/snapcraft/internal/pluginhandler/_runner.py", line 189, in _run_scriptlet
        raise error
      File "/snap/snapcraft/7201/lib/python3.8/site-packages/snapcraft/internal/pluginhandler/_runner.py", line 178, in _run_scriptlet
        self._handle_builtin_function(
      File "/snap/snapcraft/7201/lib/python3.8/site-packages/snapcraft/internal/pluginhandler/_runner.py", line 233, in _handle_builtin_function
        function(**function_args)
      File "/snap/snapcraft/7201/lib/python3.8/site-packages/snapcraft/internal/pluginhandler/__init__.py", line 511, in _do_pull
        self.source_handler.pull()
      File "/snap/snapcraft/7201/lib/python3.8/site-packages/snapcraft/internal/sources/_local.py", line 37, in pull
        file_utils.link_or_copy_tree(
      File "/snap/snapcraft/7201/lib/python3.8/site-packages/snapcraft/file_utils.py", line 245, in link_or_copy_tree
        copy_function(source, destination)
      File "/snap/snapcraft/7201/lib/python3.8/site-packages/snapcraft/file_utils.py", line 110, in link_or_copy
        copy(source, destination, follow_symlinks=follow_symlinks)
      File "/snap/snapcraft/7201/lib/python3.8/site-packages/snapcraft/file_utils.py", line 159, in copy
        shutil.copy2(source, destination, follow_symlinks=follow_symlinks)
      File "/snap/snapcraft/7201/usr/lib/python3.8/shutil.py", line 435, in copy2
        copyfile(src, dst, follow_symlinks=follow_symlinks)
      File "/snap/snapcraft/7201/usr/lib/python3.8/shutil.py", line 264, in copyfile
        with open(src, 'rb') as fsrc, open(dst, 'wb') as fdst:
    OSError: [Errno 6] No such device or address: '/run/snapd.socket'

Error 3:

+ snapcraftctl pull
`/run/initctl` is a named pipe
We would appreciate it if you anonymously reported this issue.
No other data than the traceback and the version of snapcraft in use will be sent.
Would you like to send this error data? (Yes/No/Always/View) [no]: view
Traceback (most recent call last):
  File "/snap/snapcraft/7201/lib/python3.8/site-packages/snapcraft/file_utils.py", line 100, in link_or_copy
copy(source, destination)
  File "/snap/snapcraft/7201/lib/python3.8/site-packages/snapcraft/file_utils.py", line 159, in copy
shutil.copy2(source, destination, follow_symlinks=follow_symlinks)
  File "/snap/snapcraft/7201/usr/lib/python3.8/shutil.py", line 435, in copy2
copyfile(src, dst, follow_symlinks=follow_symlinks)
  File "/snap/snapcraft/7201/usr/lib/python3.8/shutil.py", line 257, in copyfile
raise SpecialFileError("`%s` is a named pipe" % fn)
shutil.SpecialFileError: `/run/initctl` is a named pipe

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/snap/snapcraft/7201/bin/snapcraft", line 8, in <module>
sys.exit(run())
  File "/snap/snapcraft/7201/lib/python3.8/site-packages/click/core.py", line 1137, in __call__
return self.main(*args, **kwargs)
  File "/snap/snapcraft/7201/lib/python3.8/site-packages/click/core.py", line 1062, in main
rv = self.invoke(ctx)
  File "/snap/snapcraft/7201/lib/python3.8/site-packages/click/core.py", line 1668, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/snap/snapcraft/7201/lib/python3.8/site-packages/click/core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
  File "/snap/snapcraft/7201/lib/python3.8/site-packages/click/core.py", line 763, in invoke
return __callback(*args, **kwargs)
  File "/snap/snapcraft/7201/lib/python3.8/site-packages/snapcraft/cli/lifecycle.py", line 387, in snap
_execute(steps.PRIME, parts=tuple(), pack_project=True, output=output, **kwargs)
  File "/snap/snapcraft/7201/lib/python3.8/site-packages/snapcraft/cli/lifecycle.py", line 102, in _execute
lifecycle.execute(step, project_config, parts)
  File "/snap/snapcraft/7201/lib/python3.8/site-packages/snapcraft/internal/lifecycle/_runner.py", line 145, in execute
executor.run(step, part_names)
  File "/snap/snapcraft/7201/lib/python3.8/site-packages/snapcraft/internal/lifecycle/_runner.py", line 199, in run
self._handle_step(part_names, part, step, current_step, cli_config)
  File "/snap/snapcraft/7201/lib/python3.8/site-packages/snapcraft/internal/lifecycle/_runner.py", line 213, in _handle_step
getattr(self, "_run_{}".format(current_step.name))(part)
  File "/snap/snapcraft/7201/lib/python3.8/site-packages/snapcraft/internal/lifecycle/_runner.py", line 255, in _run_pull
self._run_step(step=steps.PULL, part=part, progress="Pulling")
  File "/snap/snapcraft/7201/lib/python3.8/site-packages/snapcraft/internal/lifecycle/_runner.py", line 356, in _run_step
getattr(part, step.name)()
  File "/snap/snapcraft/7201/lib/python3.8/site-packages/snapcraft/internal/pluginhandler/__init__.py", line 491, in pull
self._do_runner_step(steps.PULL)
  File "/snap/snapcraft/7201/lib/python3.8/site-packages/snapcraft/internal/pluginhandler/__init__.py", line 281, in _do_runner_step
return getattr(self._runner, "{}".format(step.name))()
  File "/snap/snapcraft/7201/lib/python3.8/site-packages/snapcraft/internal/pluginhandler/_runner.py", line 81, in pull
self._run_scriptlet(
  File "/snap/snapcraft/7201/lib/python3.8/site-packages/snapcraft/internal/pluginhandler/_runner.py", line 189, in _run_scriptlet
raise error
  File "/snap/snapcraft/7201/lib/python3.8/site-packages/snapcraft/internal/pluginhandler/_runner.py", line 178, in _run_scriptlet
self._handle_builtin_function(
  File "/snap/snapcraft/7201/lib/python3.8/site-packages/snapcraft/internal/pluginhandler/_runner.py", line 233, in _handle_builtin_function
function(**function_args)
  File "/snap/snapcraft/7201/lib/python3.8/site-packages/snapcraft/internal/pluginhandler/__init__.py", line 511, in _do_pull
self.source_handler.pull()
  File "/snap/snapcraft/7201/lib/python3.8/site-packages/snapcraft/internal/sources/_local.py", line 37, in pull
file_utils.link_or_copy_tree(
  File "/snap/snapcraft/7201/lib/python3.8/site-packages/snapcraft/file_utils.py", line 245, in link_or_copy_tree
copy_function(source, destination)
  File "/snap/snapcraft/7201/lib/python3.8/site-packages/snapcraft/file_utils.py", line 110, in link_or_copy
copy(source, destination, follow_symlinks=follow_symlinks)
  File "/snap/snapcraft/7201/lib/python3.8/site-packages/snapcraft/file_utils.py", line 159, in copy
shutil.copy2(source, destination, follow_symlinks=follow_symlinks)
  File "/snap/snapcraft/7201/usr/lib/python3.8/shutil.py", line 435, in copy2
copyfile(src, dst, follow_symlinks=follow_symlinks)
  File "/snap/snapcraft/7201/usr/lib/python3.8/shutil.py", line 257, in copyfile
raise SpecialFileError("`%s` is a named pipe" % fn)
shutil.SpecialFileError: `/run/initctl` is a named pipe

Thanks!

A suspicious line in those logs is when a local source is being copied inside the container: OSError: [Errno 18] Invalid cross-device link: '/run/snapd-snap.socket' -> '/root/parts/name_of_app/src/run/snapd-snap.socket'. That error occurs when attempting to hardlink across a filesystem boundary.

Using that, @cmatsuoka and I reproduced the same set of errors with:

name: hello-world
base: core20
version: '1.0'
summary: 'hello-world'
description: 'hello-world'
grade: devel
confinement: devmode

parts:
  hello-world:
    plugin: dump
    source: /run

Above, the source: /run is the cause of the troubles. Snapcraft is unable to copy the sockets in /run.

Are you able to share your snapcraft.yaml? Perhaps some directory is being sourced unintentionally.

1 Like

@mr_cal Here is my yaml file:

name: WICKRLCAPPNAME
version: WICKRVERSIONNUM
summary: Secure Messaging for Teams
description: >
  Wickr Secure Messaging

grade: stable
confinement: strict
base: core18
icon: snap/gui/WICKRLCAPPNAME.png

apps:

  WICKRLCAPPNAME:
    environment:
      DISABLE_WAYLAND: 1
      QT_QPA_PLATFORMTHEME: gtk3  
    command: desktop-launch alsa-launch WICKRAPPNAME
    plugs:
    - alsa
    - audio-playback
    - audio-record
    - desktop
    - desktop-legacy
    - x11
    - unity7
    - wayland
    - gsettings
    - opengl
    - home
    - removable-media
    - network
    - network-bind
    - network-manager
    - network-observe
    - network-control
    - camera
    - screen-inhibit-control
    - raw-usb

parts:
  qt515:
    plugin: dump
    source: /opt/qt51512/qt51512_5.15.12-wickr_amd64.deb
    source-type: deb

  wickr:
    source: ../../../ #this is relative to the "parts" directory that's created by snapcraft
    project-files: ["../../../../../desktop.pro"]  #this is relative to the "parts/wickr/src" directory
    plugin: qmakeppa
    after: [alsa-mixin, desktop-qt5]
    options: [WICKRQMAKECONFIGS]
    override-prime: |
      snapcraftctl prime

  alsa-mixin:
    plugin: nil
    source: https://github.com/diddlesnaps/snapcraft-alsa.git
    override-pull: |
      cat > asound.conf <<EOF
      pcm.!default {
          type pulse
          fallback "sysdefault"
          hint {
              show on
              description "Default ALSA Output (currently PulseAudio Sound Server)"
          }
      }
      ctl.!default {
          type pulse
          fallback "sysdefault"
      }
      EOF
      cat > alsa-launch <<EOF
      #!/bin/bash
      export ALSA_CONFIG_PATH="\$SNAP/etc/asound.conf"

      if [ -d "\$SNAP/usr/lib/alsa-lib" ]; then
          export LD_LIBRARY_PATH="\$LD_LIBRARY_PATH:\$SNAP/usr/lib/alsa-lib"
      elif [ -d "\$SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/alsa-lib" ]; then
          export LD_LIBRARY_PATH="\$LD_LIBRARY_PATH:\$SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/alsa-lib"
      fi
      export LD_LIBRARY_PATH="\$LD_LIBRARY_PATH:\$SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/pulseaudio"
      export LD_LIBRARY_PATH="\$LD_LIBRARY_PATH:\$SNAP/opt/qt51512/lib"

      # Make PulseAudio socket available inside the snap-specific $XDG_RUNTIME_DIR
      if [ -n "\$XDG_RUNTIME_DIR" ]; then
          pulsenative="pulse/native"
          pulseaudio_sockpath="\$XDG_RUNTIME_DIR/../\$pulsenative"
          if [ -S "\$pulseaudio_sockpath" ]; then
              export PULSE_SERVER="unix:\${pulseaudio_sockpath}"
          fi
      fi

      exec "\$@"
      EOF
      chmod +x alsa-launch
    override-build: |
      snapcraftctl build
      install -m644 -D -t $SNAPCRAFT_PART_INSTALL/etc asound.conf
      install -m755 -D -t $SNAPCRAFT_PART_INSTALL/snap/command-chain alsa-launch
    build-packages:
      - libasound2-dev
    stage-packages:
      - libasound2
      - libasound2-plugins

  ppa:
    plugin: nil
    override-pull: |
      QT_BASE_DIR=/opt/qt51512
      export QTDIR=$QT_BASE_DIR
      export PATH=$QT_BASE_DIR/bin:$PATH
      export LD_LIBRARY_PATH=$QT_BASE_DIR/lib:$LD_LIBRARY_PATH
      export PKG_CONFIG_PATH=$QT_BASE_DIR/lib/pkgconfig:$PKG_CONFIG_PATH

  desktop-qt5:
    source: https://github.com/spompelio/snapcraft-desktop-helpers.git
    source-commit: 6a4a132be505da069485473bb5f486afd69f28ba
    source-subdir: qt
    plugin: make
    after: [qt515, ppa]
    make-parameters: ["FLAVOR=qt5"]
    build-packages:
      - build-essential
      - dpkg-dev
    override-stage: |
        snapcraftctl stage
        strip --remove-section=.note.ABI-tag opt/qt51512/lib/libQt5Core.so.5
    override-prime: |
      snapcraftctl prime
      cp /usr/share/glib-2.0/schemas/org.gtk.Settings.FileChooser.gschema.xml usr/share/glib-2.0/schemas
      glib-compile-schemas usr/share/glib-2.0/schemas
    stage-packages:
      - ttf-ubuntu-font-family
      - dmz-cursor-theme
      - light-themes
      - adwaita-icon-theme
      - gnome-themes-standard
      - shared-mime-info
      - libgdk-pixbuf2.0-0
      - locales-all
      - xdg-user-dirs
      - libgtk2.0-0
      - libavahi-client3
      - libavahi-common3
      - libboost-all-dev
      - libcapnp-0.6.1
      - libcups2
      - libgbm1
      - libflac-dev
      - libxcomposite1
      - libxcursor1
      - libxi6
      - libxrender1
      - libxss1
      - libxtst6
      - libasyncns0
      - libfontconfig1
      - libhunspell-1.6-0
      - libnspr4
      - libnss3
      - libogg0
      - libpulse0
      - libsndfile1
      - libvorbis0a
      - libvorbisenc2
      - libxml2
      - libxslt1.1
      - gstreamer1.0-plugins-base
      - gstreamer1.0-plugins-good
      - libslang2
      - liborc-0.4-0
      - libxcb-xfixes0
      - libwayland-client0
      - libwayland-cursor0
      - libwayland-egl1
      - libglu1-mesa
      - libgl1-mesa-dri
      - libmtdev1
      - libdb5.3
      - libgl1-mesa-glx
      - libgpm2
      - libxcb-glx0
      - libxxf86vm1
      - libdouble-conversion1
      - libxcb1
      - libsm6
      - libice6
      - libxrandr2
      - libxcb-xkb1
      - libxcb-render-util0
      - libxcb-randr0
      - libxcb-image0
      - libxcb-keysyms1
      - libxcb-icccm4
      - libxcb-shape0
      - libxcb-util1
      - libxcb-xinput0
      - libxcb-xinerama0
      - xkb-data
      - libxkbcommon0
      - libxkbcommon-x11-0
      - libuuid1
      - zlib1g
      - libsystemd0
      - liblzma5
      - liblz4-1
      - libgpg-error0
      - libsqlcipher0
      - libpsm-infinipath1
      - libstdc++6
      - xdg-utils
      - libc-bin

passthrough:
  layout:
    /etc/asound.conf:
      bind-file: $SNAP/etc/asound.conf
    /usr/lib/$SNAPCRAFT_ARCH_TRIPLET/alsa-lib:
      bind: $SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/alsa-lib
    /usr/share/alsa/alsa.conf:
      bind-file: $SNAP/usr/share/alsa/alsa.conf

plugs:
  # Support for common GTK themes
  # https://forum.snapcraft.io/t/how-to-use-the-system-gtk-theme-via-the-gtk-common-themes-snap/6235
  gsettings:
  gtk-3-themes:
    interface: content
    target: $SNAP/data-dir/themes
    default-provider: gtk-common-themes
  icon-themes:
    interface: content
    target: $SNAP/data-dir/icons
    default-provider: gtk-common-themes
  sound-themes:
    interface: content
    target: $SNAP/data-dir/sounds
    default-provider: gtk-common-themes
  browser-sandbox:
    interface: browser-support
    allow-sandbox: false

This is the problem:

Your source is a regular file path pointing to a location outside of the project. When snapcraft makes your project available to the container to run the build, this path likely ends up pointing at the root of the container.

Then some code that expects to only be copying regular files from the part source ends up trying to copy the entire container file system, including special files like devices and sockets.

The fix is to ensure all your part sources are either URLs, or relative paths within the snapcraft project.

2 Likes

@mr_cal Sorry what is happening? I am currently trying to resolve the issue with the information that has been given. I appreciate the help!

Sure, I made a post, realized James already answered the question, then deleted my answer.

To re-answer and elaborate, the problem arises with this section:

wickr:
  source: ../../../

In a snapcraft managed LXD container, the relative directory when pulling this source is /root/project, so ../../../ evaluates to /.

Snapcraft attempts to copy the contents of filesystem into /root/parts/wickr/src, which causes an error when copying sockets like /run/snapd-snap.socket.

I would recommend updating the source to be inside your project directory and relative. By “inside your project directory”, I mean do not use source: ../ to point to a filepath outside the project directory. By relative, I mean source: ./path/inside/project/ or source: path/inside/project/, both are equivalent.

2 Likes

Thank you @mr_cal and @jamesh! That was indeed the issue. In the previous build (on a 18.04 machine) the …/…/…/ scheme would correctly move to the wanted folder as the build directory was held in that respective part’s directory. So to fix the issue I had to create a directory on the container, mount the directory to it, and then for that part do the correct …/… etc. scheme to get to it. But now I have a different error. :frowning:

If you are able to help with this issue:

Building wickr 
+ snapcraftctl build
/opt/qt51512/bin/qmake 'LIBS+="-L/root/stage/lib"' 'LIBS+="-L/root/stage/usr/lib"' 'LIBS+="-L/root/stage/lib/x86_64-linux-gnu"' 'LIBS+="-L/root/stage/usr/lib/x86_64-linux-gnu"' 'INCLUDEPATH+="/root/stage/usr/include"' 'INCLUDEPATH+="/root/stage/usr/include/x86_64-linux-gnu"' CONFIG+=aws_wickr_branding CONFIG+=release CONFIG+=use_wickr_npl CONFIG+=qzxing_multimedia CONFIG+=qtquickcompiler CONFIG+=wickr_alpha CONFIG+=use_autoloader CONFIG+=snapcraft /root/parts/wickr/src/../../../../WickrDesktopApp/desktop.pro
/opt/qt51512/bin/qmake: /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.29' not found (required by /opt/qt51512/bin/qmake)
/opt/qt51512/bin/qmake: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28' not found (required by /opt/qt51512/bin/qmake)
Failed to run '/opt/qt51512/bin/qmake \'LIBS+="-L/root/stage/lib"\' \'LIBS+="-L/root/stage/usr/lib"\' \'LIBS+="-L/root/stage/lib/x86_64-linux-gnu"\' \'LIBS+="-L/root/stage/usr/lib/x86_64-linux-gnu"\' \'INCLUDEPATH+="/root/stage/usr/include"\' \'INCLUDEPATH+="/root/stage/usr/include/x86_64-linux-gnu"\' CONFIG+=aws_wickr_branding CONFIG+=release CONFIG+=use_wickr_npl CONFIG+=qzxing_multimedia CONFIG+=qtquickcompiler CONFIG+=wickr_alpha CONFIG+=use_autoloader CONFIG+=snapcraft /root/parts/wickr/src/../../../../WickrDesktopApp/desktop.pro' for 'wickr': Exited with code 1.
Verify that the part is using the correct parameters and try again.

Im thinking it could possibly be because my version of qt51512 is oriented for ubuntu 20.04 (current machine is 20.04) but the the container might be 18.04. or at least when I run " cat /etc/lsb-release" in the terminal on the container it says:

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.6 LTS"

On local with cat /etc/lsb-release it gives:

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04.6 LTS"

So is there a way for the container to be 20.04? I ran ldd --version on local and the container.

For local I get:

ldd (Ubuntu GLIBC 2.31-0ubuntu9.9) 2.31
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.

On the container I get:

ldd (Ubuntu GLIBC 2.27-3ubuntu1.6) 2.27
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.

Unsure though.

Snapcraft will run your build in an environment similar to the runtime your snap will use. As you’ve specified base: core18, the build container uses Ubuntu 18.04.

I would strongly recommend using a newer base at this point: you’ll have access to newer software, and they will remain in support longer. I’d suggest going straight to base: core22 if possible.

@jamesh Ok that does make sense! But, then would it not be possible to have backwards compatibility with 18.04? That is why I was trying to keep it. But so far it looks like it might not be possible as the qt5.15.12 build I am using for 18.04 wants libraries that are not supported anymore.

When trying to unload qt51512 for 18.04 on the container:

dpkg: dependency problems prevent configuration of qt51512:
 qt51512 depends on libstdc++6 (>= 9); however:
  Version of libstdc++6:amd64 on system is 8.4.0-1ubuntu1~18.04.

When trying to get a newer libstdc++6 with apt upgrade that 8.4 is there highest, therefore cannot move forward.

When trying to unload qt51512 for 18.04 on the local 20.04:

It was complaining about needing dependencies but when trying to download them:

E: Package 'libdouble-conversion1' has no installation candidate
E: Package 'libevent-2.1-6' has no installation candidate
E: Package 'libhunspell-1.6-0' has no installation candidate
E: Package 'libicu60' has no installation candidate
E: Package 'libmysqlclient20' has no installation candidate

So those libraries dont go/exist for 20.04, therefore cannot move forward.

And then alternatively when trying to use the 20.04 qt51512 with the 18.04 container, the glibc errors ensue. So I would be forced to use base20 or higher right and lose backwards compatibility with 18.04?

Also part of the reason I was keeping base18 was because we are using a custom plugin qmakeppa where we defined a python file with the standard class stuff with added things. How do I redo that for 20.04 and snapcraft7? I deliberately have snapcraft6.1 because of that as well.

The plugin snap/plugins/qmakeppa.py (referenced in the wickr part of the yaml file given above):

# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*-
#
# Copyright (C) 2016 Canonical Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

"""The qmake plugin is useful for building qmake-based parts.

These are projects that are built using .pro files.

This plugin uses the common plugin keywords as well as those for "sources".
For more information check the 'plugins' topic for the former and the
'sources' topic for the latter.

Additionally, this plugin uses the following plugin-specific keywords:

    - options:
      (list of strings)
      additional options to pass to the qmake invocation.
    - qt-version:
      (string; default: qt5)
      Version of Qt to use with qmake. Valid options are: qt5
    - project-files:
      (list of strings)
      list of .pro files to pass to the qmake invocation.
"""

import os

import snapcraft
from snapcraft import common


class QmakePlugin(snapcraft.BasePlugin):
    @classmethod
    def schema(cls):
        schema = super().schema()
        schema["properties"]["options"] = {
            "type": "array",
            "minitems": 1,
            "uniqueItems": True,
            "items": {"type": "string"},
            "default": [],
        }
        schema["properties"]["qt-version"] = {
            "type": "string",
            "enum": ["qt5"],
            "default": "qt5",
        }
        schema["properties"]["project-files"] = {
            "type": "array",
            "minitems": 1,
            "uniqueItems": True,
            "items": {"type": "string"},
            "default": [],
        }

        schema.pop("required")

        return schema

    @classmethod
    def get_pull_properties(cls):
        # Inform Snapcraft of the properties associated with pulling. If these
        # change in the YAML Snapcraft will consider the pull step dirty.
        return ["qt-version"]

    @classmethod
    def get_build_properties(cls):
        # Inform Snapcraft of the properties associated with building. If these
        # change in the YAML Snapcraft will consider the build step dirty.
        return ["options", "project-files"]

    def __init__(self, name, options, project):
        super().__init__(name, options, project)

        self.build_packages.append("make")

    def build(self):
        super().build()

        env = self._build_environment()

        sources = []
        if self.options.project_files:
            sourcedir = self.sourcedir
            source_subdir = getattr(self.options, "source_subdir", None)
            if source_subdir:
                sourcedir = os.path.join(sourcedir, source_subdir)
            sources = [
                os.path.join(sourcedir, project_file)
                for project_file in self.options.project_files
            ]

        self.run(
            ["/opt/qt51512/bin/qmake"] + self._extra_config() + self.options.options + sources, env=env
        )

        self.run(["make", "-j{}".format(self.parallel_build_count)], env=env)

        self.run(["make", "install", "INSTALL_ROOT=" + self.installdir], env=env)

        self.run(["cp", "/opt/qt51512/resources/icudtl.dat", self.installdir + "/usr/bin"], env=env)
        self.run(["cp", "/opt/qt51512/resources/qtwebengine_devtools_resources.pak", self.installdir + "/usr/bin"], env=env)
        self.run(["cp", "/opt/qt51512/resources/qtwebengine_resources_100p.pak", self.installdir + "/usr/bin"], env=env)
        self.run(["cp", "/opt/qt51512/resources/qtwebengine_resources_200p.pak", self.installdir + "/usr/bin"], env=env)
        self.run(["cp", "/opt/qt51512/resources/qtwebengine_resources.pak", self.installdir + "/usr/bin"], env=env)
        self.run(["cp", "/opt/qt51512/libexec/QtWebEngineProcess", self.installdir + "/usr/bin"], env=env)

    def _extra_config(self):
        extra_config = []

        for root in [self.installdir, self.project.stage_dir]:
            paths = common.get_library_paths(root, self.project.arch_triplet)
            for path in paths:
                extra_config.append('LIBS+="-L{}"'.format(path))

            paths = common.get_include_paths(root, self.project.arch_triplet)
            for path in paths:
                extra_config.append('INCLUDEPATH+="{}"'.format(path))

        return extra_config

    def _build_environment(self):
        env = os.environ.copy()
        env["QT_SELECT"] = self.options.qt_version

        return env

When you install a snap, snapd will make sure the corresponding base snap is also installed. When you run the snapped application, it will be run in a sandbox created using a private mount namespace that uses the base snap as the root file system.

As an example, I have the Skype snap installed on my system that is using the core18 snap. So it runs in an environment that looks like Ubuntu 18.04 (snap run --shell starts a shell in the sandbox a snap would run in):

$ snap run --shell skype
+ [ -f /home/james/snap/skype/common/.config/skypeforlinux/settings.json ]
+ export SKYPE_LOGS=/home/james/snap/skype/271/logs
+ [ ! -d /home/james/snap/skype/271/logs ]
+ exec /bin/bash
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

james@lrrr:/home/james$ cat /usr/lib/os-release
NAME="Ubuntu Core"
VERSION="18"
ID=ubuntu-core
PRETTY_NAME="Ubuntu Core 18"
VERSION_ID="18"
HOME_URL="https://snapcraft.io/"
BUG_REPORT_URL="http://bugs.launchpad.net/snappy/"

In contrast, the Firefox snap on my system runs in an environment that looks like Ubuntu 22.04:

$ snap run --shell firefox
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

james@lrrr:/home/james$ cat /usr/lib/os-release
NAME="Ubuntu Core"
VERSION="22"
ID=ubuntu-core
PRETTY_NAME="Ubuntu Core 22"
VERSION_ID="22"
HOME_URL="https://snapcraft.io/"
BUG_REPORT_URL="https://bugs.launchpad.net/snappy/"

While these two runtimes are older than my Ubuntu 23.04 install, this same system works to run snaps that depend on newer base snap runtimes than the host system.

The snap apps are still running against the host system kernel, so it doesn’t help if your app depends on new kernel features. But if you just need newer user space libraries, it works well as a way to deploy new apps on old systems.

@jamesh Ah ok I see! I had to manually download some libraries from http://archive.ubuntu.com/ubuntu/pool/main, http://archive.ubuntu.com/ubuntu/pool/main, and https://dev.mysql.com/downloads/mysql/5.7.html and then was unable to unpack my qt51512 for 18.04 properly on my 20.04 machine. I am running into other issues… as building is a tough task. But thank you!!

1 Like