Commands work in shell, but not installed

Hi Folks,

Trying to make a snap where I need this cmake builld from source.

If I do snapcraft --shell, I can then launch my command /usr/bin/gst-inspect-1.0 without any problems, and get the desired output.

However, after I install my snap, it doesn’t work anymore I get exec: /usr/bin/gst-inspect-1.0: not found

I do notice that folders bin, usr and lib aren’t to be found in the snap folder after it is installed.

How do I get those folders to be in the snap?

Thanks!

Current snapcraft.yaml file :

architectures:
  - build-on: amd64
    run-on: amd64

confinement: devmode

base: core18

apps:

  inspect:
      command: /usr/bin/gst-inspect-1.0
      plugs: [camera,framebuffer]

  stream:
      command: /usr/bin/gst-launch-1.0 tcambin ! video/x-raw, format=GRAY8, width=640, height=480, framerate=60/1 ! videoconvert ! fbdevsink
      plugs: [camera,framebuffer]


parts:
  tis:
    source-type: git
    source: https://github.com/TheImagingSource/tiscamera
    plugin: cmake
    override-build: |
       cd $SNAPCRAFT_PART_SRC
       cd scripts
       yes | ./install-dependencies.sh --compilation --runtime
       cd $SNAPCRAFT_PART_SRC   
       mkdir -p build
       cd build
       echo "Going to CMAKE"
       cmake \
          -DCMAKE_INSTALL_PREFIX=$SNAPCRAFT_STAGE/cmake \
          -DBUILD_ARAVIS=OFF \
          -DBUILD_TOOLS=ON \
          -DBUILD_GST_1_0=ON \
          $SNAPCRAFT_PART_SRC
       echo "Going to make"
       make
       echo "Going to make install"
       make install

Try remove leading /, or even /usr/bin/ from command:. It just tries run executable from root filesystem, not from snap.

From snapcraft.yaml reference:

The command can be in either a snap runtime’s command path, $SNAP/usr/sbin:$SNAP/usr/bin:$SNAP/sbin:$SNAP/bin , or an executable path relative to $SNAP.

1 Like

unfortunately that didn’t help.

I do get a message when I snap that says the command path was changed to /usr/bin/gst-inspect-1.0

You’re running install-dependencies.sh which runs apt to install the packages that the application uses. This should be removed and replaced with build-packages and stage-packages within the snapcraft.yaml, because the snap won’t include any of the files from the relevant packages when installing dependencies with your script.

You can find the packages for each of the build-packages and stage-packages within your repo in the files dependencies-debian-compilation.txt and dependencies-debian-runtime.txt respectively. The entries in the snapcraft.yaml need to be just the package names, without version information, so you can’t simply copy and paste those files into the yaml.

1 Like

Fair enough, I thought I would be wiser using their script, that way if they add a dependency the next time I pull from the git it would automatically get it.

If I put all the packages in build and stage, what do I do if there are duplicates? Build doesn’t automatically get put in stage right?

Also, if I have two parts requiring the same stage dependencies, do I need both parts to call it out, or is one mention enough for the whole snap?

If a package is used for building and for runtime then it needs to be specified in both lists - the build-packages are installed to the build machine so that you can compile against them, they aren’t copied into the snap. The stage packages are only installed into the snap for runtime use, so can’t be used for building against.

If you have shared dependencies between parts, you can specify the same package in both parts, or you can make sure one part runs after the other and ensure you specify the build-package in the first part, or you can pull out the packages to a third part that just defines the packages with plugin: nil so that it only installs the packages and the make both your original parts run after the dependencies part.

1 Like