I get this error on ubuntu 20.04 (my snapcraft.yaml has core20 as well), I run “snapcraft --use-lxd”:
Pulling alsa-mixin
/bin/bash: line 46: XDG_RUNTIME_DIR: unbound variable
Failed to run 'override-pull': Exit code was 1.
I did not have this issue with core18. I have tried adding
lxc exec $containername -- bash -c "export XDG_RUNTIME_DIR=/run/user/$UID"
in my pre snapcraft script. I also tried adding “export XDG_RUNTIME_DIR=/run/user/$UID” right above where XDG_RUNTIME_DIR gets called in my snapcraft.yaml file.
The part in my yaml file where it is getting called:
alsa-mixin:
plugin: nil
source: https://github.com/diddlesnaps/snapcraft-alsa.git
override-pull: |
echo $PWD
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"
export XDG_RUNTIME_DIR=/run/user/$UID
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: |
# had to change to craft from snapcraft, it was changed
snapcraftctl build
install -m644 -D -t $CRAFT_PART_INSTALL/etc asound.conf
install -m755 -D -t $CRAFT_PART_INSTALL/snap/command-chain alsa-launch
build-packages:
- libasound2-dev
stage-packages:
- libasound2
- libasound2-plugins
That XDG_RUNTIME_DIR section is from Audio-playback interface in snaps running in daemon mode
How do I fix this? I tried seeing what env variables are on the lxc container. XDG_RUNTIME_DIR was not in there.