How to record audio on Snap? Jack server is not running or cannot be started

You need to set up a bit more config to get the Alsa → Pulse backend working.

  1. You need this file somewhere in $SNAP, e.g., $SNAP/etc/asound.conf
pcm.!default {
        type pulse
        fallback "sysdefault"
        hint {
                show on
                description "Default ALSA Output (currently PulseAudio Sound Server)"
        }
}
ctl.!default {
        type pulse
        fallback "sysdefault"
}
  1. You need these stage packages
      - libasound2
      - libasound2-plugins
  1. You need this environment variable
environment:
      ALSA_CONFIG_PATH: $SNAP/etc/asound.conf
  1. You need the Gnome extension (which includes libpulse0 and modifies the environment to correctly connect to a Pulseaudio socket, including the one provided by Pipewire).

  2. You need audio-playback in the interfaces (which the extension does automatically).

  3. Since you’ve mentioned recording, you’ll also want audio-record as an interface, which the extension does not do automatically, and will require manual connection or store approval to be overridden on install for your users.

This covers any arbitrary use of ALSA as a userspace library for simple input/output needs (which currently is all Java apps except for a specific niche of Java 8 from the Ubuntu/Debian repositories which actually has direct PulseAudio support through custom patches that were later removed), it doesn’t cover more advanced ALSA features like MIDI keyboards, which would need direct ALSA access and is a fair bit more complex (and usually unnecessary, and not preferred as a default on modern setups because it can do things like lock the soundcard from other apps).