Path to snaps internal staging path?

adsiltia@PCPAT-CEM96SO:~$ snap run space-nerds-in-space Failed to read /proc/self/attr/current: Invalid argument /snap/space-nerds-in-space/x41/bin/snis_client asset dir = /home/adsiltia/.local/share/space-nerds-in-space/share/snis ALSA lib conf.c:4579:(snd_config_update_r) Cannot access file /usr/share/alsa/alsa.conf snis_client: src/hostapi/alsa/pa_linux_alsa.c:1454: BuildDeviceList: Assertion `devIdx < numDeviceNames’ failed. Aborted (core dumped)

I am assuming I need to set the snap path to point to alsa.conf

Why does the following not work, or compile. If I leave $(SNAP} out it seems to point to my WSL path but /usr/share/alsa is not accessible.

What is the correct way to point to the internal staging path in the snap?

environment:

PATH: ${PATH}:${SNAP}/usr/share/alsa/

Could you share the snapcraft.yaml file?

It’s rather difficult to understand the problem with so little information.

OK, but it is pretty ugly (comments and the like) as I am thrashing about trying to make sense of the snapcraft documentation. It compiles with snapcraft and will run without error outside the snap environment (WSL) under the /snap/ space-nerds-in-space folder. I get the error

Cannot access file /usr/share/alsa/alsa.conf

when running the snap. My guess is that I have to manually enable the ALSA interface, but that did not seem to work. See https://snapcraft.io/docs/alsa-interface

name: space-nerds-in-space
adopt-info: snis-part
type: app
base: core24
#build-base: devel
#platforms:
 # amd64:
  #  build-on: [amd64]
   # build-for: [amd64]
  #arm64:
    #build-on: [arm64]
    #build-for: [arm64]
version: 1.0.8
summary: Space bridge simulator
description: |
  Space bridge simulator
#grade: devel #?
confinement: devmode

apps:
  space-nerds-in-space:
    #command: desktop-launch $SNAP/usr/bin/io.github.smcameron.space-nerds-in-space.desktop
    command: ./bin/snis_client
    common-id: io.github.smcameron.space-nerds-in-space
#OR ----------------
    #desktop: usr/share/apps/io.github.smcameron.space-nerds-in-space.desktop
    plugs: #for interfacing with host resources
      - desktop
      - desktop-legacy
      - home
      #- dbus 
      # for xdg-desktop-por[3870]: cannot open display: https://forum.snapcraft.io/t/snapd-support-for-xdg-desktop-portal/161/3
      - alsa
      - audio-playback 
      #- audio-record
      #- jack1
      - joystick
      - network
      - opengl
      #- pipewire
      - pulseaudio
      - x11
      #- wayland
    #jesus linux! https://forum.snapcraft.io/t/lib-exists-but-i-am-getting-error-while-loading-shared-libraries/47424/5
    environment:
      #XDG_DATA_DIRS: $SNAP_USER_DATA
      LD_LIBRARY_PATH: ${LD_LIBRARY_PATH}:${SNAP}/usr/lib:${LD_LIBRARY_PATH}:${SNAP}/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/pulseaudio #$CRAFT_ARCH_TRIPLET_BUILD_FOR is only seen at build time
      HOME: /home/$USER #snapcraft sets to virtual read only area in $SNAP . why?
      #PATH: ${PATH}:/usr/share/alsa/ #?
      #HOME: ${SNAP_REAL_HOME}
      PULSE_SERVER: unix:/run/user/1000/pulse/native

parts:
  snis-part:
    source: ./space-nerds-in-space
    #source-type: local
    parse-info:
      - share/metainfo/io.github.smcameron.space-nerds-in-space.metainfo.xml.template
    #source: https://github.com/smcameron/space-nerds-in-space.git
    #source: https://github.com/bridgecommand/bc.git
    #source: ./bc
    #source-subdir: src
    #source-type: git
    plugin: make
    make-parameters:
      - -C . # set make directory
      - PREFIX= #must clear default . in makefile or will mangle command path
      - DOWNLOAD_OPUS=no
      - WITHVOICECHAT=no
      - WITHVOICECHAT=yes 
    stage-packages:
      - pkg-config
      - pulseaudio
      - libportaudio2
      - libsdl2-2.0-0
      - libttspico-utils
      - libopus0 
      - libubsan1
      - libglew-dev
      - libvorbis-dev
      - xorg
      #- libpulse0 #?
      #- libpulse-dev # ?
      #- portaudio19-dev #?
      - libasound2 # for alsa https://snapcraft.io/docs/alsa-interface
      #- libasound-dev #?      
      #- libgl1  #?
      #- libglx-mesa0 #?
    build-packages:
      - git
      - pkg-config
      - curl
      - libpng-dev
      - libvorbis-dev
      - libsdl2-dev
      - liblua5.2-dev    # .3 fails?
      - libglew-dev
      - libssl-dev
      - libcrypt-dev
      - libcurl4-gnutls-dev
      - libopus-dev
      - portaudio19-dev
      #- libasound-dev
      #- libpulse-dev
      #- xorg

I opened this repository; you can download its contents and try creating the Snap.

You can see that snapcraft.yaml has fewer plugs; this is because the kde-neon-6 extension already adds several essential ones.

https://documentation.ubuntu.com/snapcraft/stable/reference/extensions/kde-neon-extensions/

There are several layouts because, for some reason, the files weren’t being found, so I added all of this to ensure it worked.

Thank you very much for your time and expertise.

This is a lot to chew on.

I wanted to walk before I ran. I feel like you gave me all the tools I needed and pushed me off the cliff. I will try to evaluate those tools on the way down.

For those here who are are starting out, as I am, I will try and post why and where my yaml had failed, and how to fix once I figure out why. I imagine there will be a large host of reasons. One is likely related to what Kyuyrii noticed that some files were not accessible for some strange reason.

I certainly think that looking at a correctly formatted yaml snapcraft file ( GitHub - Kyuyrii/Example-Snap-space-nerds-in-space ) has already taught me more than the hours I spent going through all the official documentation.

1 Like