Environment paths only work if link to my home directory?

Hi Folks,

I’m having problems with environment paths in my snap.

I need to manually declare certain paths for an app to work in my snap, but it’s the path itself that is troublesome.

For example, this app:

inspect:
      command: gst-inspect-1.0
      environment:
          LD_LIBRARY_PATH: $LD_LIBRARY_PATH:$SNAP/home/ubuntu/mysnaps/snaps/parts/tis/install/usr/lib/aarch64-linux-gnu/gstreamer-1.0:$SNAP/lib/tcam-0
          GST_PLUGIN_PATH: $SNAP/usr/lib/aarch64-linux-gnu/gstreamer-1.0:$SNAP/home/ubuntu/mysnaps/snaps/parts/tis/install/usr/lib/aarch64-linux-gnu/gstreamer-1.0:$SNAP/lib/tcam-0
          GST_PLUGIN_SYSTEM_PATH : $SNAP/usr/lib/aarch64-linux-gnu/gstreamer-1.0
          GST_PLUGIN_SCANNER: $SNAP/usr/lib/aarch64-linux-gnu/gstreamer1.0/gstreamer-1.0/gst-plugin-scanner

As you can see, it has $SNAP/home/ubuntu and even goes so far as having aarch64-linux-gnu in the paths.

This is making it hard to build for different architectures, as I need a snap per architecture, and for the home paths, it means that I got to make sure that every computer it’s built on has it. I am assuming the build service wont work either.

Any help to make these paths functional, but build computer agnostic would be fantastic!

What am I doing wrong?

Thanks!

It seems strange to me that you need $SNAP/home/..., but that is presumably due to “other things” in your packaging recipe that you’ve not shared.

The architecture element is easy to address: ${SNAPCRAFT_ARCH_TRIPLET}

HTH

Thats for the SNAPCRAFT_ARCH_TRIPLET, I will give that a whirl.

I’m confused as to the $SNAP/home as well, expecially since my resulting file will work once installed on a another system that doesn’t have those files in my home directory.

But if I remove that path, my commands dont find the libraries needed.

Full snapcraft.yaml

    name: camera-dev
version: '1.02'
summary: Camera
description: |
  Snap to control kiosk camera.
grade: devel

architectures:
  - build-on: arm64
    run-on: arm64

confinement: devmode

base: core18

apps:
  stream:
      command: gst-launch-1.0 tcambin ! video/x-raw, format=GRAY8, width=640, height=480, framerate=60/1 ! videoconvert ! fbdevsink
      plugs: [camera,framebuffer]
      environment:
          LD_LIBRARY_PATH: $LD_LIBRARY_PATH:$SNAP/home/ubuntu/mysnaps/snaps/parts/tis/install/usr/lib/aarch64-linux-gnu/gstreamer-1.0:$SNAP/lib/tcam-0
          GST_PLUGIN_PATH: $SNAP/usr/lib/aarch64-linux-gnu/gstreamer-1.0:$SNAP/home/ubuntu/mysnaps/snaps/parts/tis/install/usr/lib/aarch64-linux-gnu/gstreamer-1.0:$SNAP/lib/tcam-0
          GST_PLUGIN_SYSTEM_PATH : $SNAP/usr/lib/aarch64-linux-gnu/gstreamer-1.0
          GST_PLUGIN_SCANNER: $SNAP/usr/lib/aarch64-linux-gnu/gstreamer1.0/gstreamer-1.0/gst-plugin-scanner

parts:
  tis:
    source-type: git
    source: https://github.com/TheImagingSource/tiscamera
    plugin: cmake
    build-packages:
            - gstreamer1.0-tools
            - git
            - g++
            - pkg-config
            - uuid-dev
            - libudev-dev
            - libgstreamer1.0-dev
            - libgstreamer1.0-0
            - libgstreamer-plugins-base1.0-dev
            - libglib2.0-dev
            - libgirepository1.0-dev
            - libusb-1.0-0-dev
            - libzip-dev
            - python3-setuptools
            - libusb-1.0-0
            - libgl1
            - libglvnd0
            - libglx0
            - libgpm2
            - libslang2
            - uvcdynctrl # needed to load up uvc extension units
    stage-packages:
            - gstreamer1.0-tools
            - libusb-1.0-0
            - libgstreamer1.0-0
            - libgstreamer1.0-dev
            - libgstreamer-plugins-base1.0-0
            - gstreamer1.0-plugins-good
            - gstreamer1.0-plugins-bad
            - liborc-0.4-0
            - libpcre2-8-0
            - udev
            - uvcdynctrl # needed for udev rules
            - libgpm2
            - libslang2
            - libglu1-mesa
            - freeglut3

Any ideas on how I can get the /home/useraccount/ out of the environment variables?

Thanks!

What errors do you see if you omit /home/… from these paths?

when I run the .stream I get the error:

WARNING: erroneous pipeline: no element “tcambin”

Meaning that it can’t find the elements it needs to run the camera.

The crucial bit is in GST_PLUGIN_PATH.

Without $SNAP/home/ubuntu/mysnaps/snaps/parts/tis/install/usr/lib/aarch64-linux-gnu/gstreamer-1.0 it wont run, with it the camera starts up and works as it should.

This looks like it’s saving files into the snap using the path that they’re installed into during the build step. Specifically this means /home/ubuntu/mysnaps/snaps/parts/tis/install/usr. Try using override-build to move the files to the correct location:

parts:
  tis:
    ...
    override-build: |
      snapcraftctl build

      # the $SNAPCRAFT_PART_INSTALL is duplicated in the gstreamer-1.0 path,
      # so move the files back to the correct location
      mv $SNAPCRAFT_PART_INSTALL/$SNAPCRAFT_PART_INSTALL/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/gstreamer-1.0/* $SNAPCRAFT_PART_INSTALL/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/gstreamer-1.0/

      # remove the remaining duplicated paths
      rm -rf $SNAPCRAFT_PART_INSTALL/home
2 Likes

You guys are magic!

That was exactly what was needed!

1 Like