Flutter run process doesn't work

Hello again!

There is a Flutter application. After publishing and installing with Snap application cannot start a system process, but in IDE all works good.

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: ProcessException: No such file or directory
  Command: pactl list sources
#0      _ProcessImpl._start (dart:io-patch/process_patch.dart:401)
#1      Process.start (dart:io-patch/process_patch.dart:38)
#2      _runNonInteractiveProcess (dart:io-patch/process_patch.dart:578)
#3      Process.run (dart:io-patch/process_patch.dart:49)
#4      LinuxInitializer.recognizeAudioDevices (package:mindrecorder/desktop_view/settings/system/linux_initializer.dart:52)
#5      LinuxInitializer.getInputDevices (package:mindrecorder/desktop_view/settings/system/linux_initializer.dart:23)
#6      ScreenRecorder.getInputDevices (package:mindrecorder/desktop_view/screen_recorder/screen_recorder.dart:114)
#7      RecordingSettingsViewModel.onReady (package:mindrecorder/desktop_view/settings/recording_settings_vm.dart:70)
<asynchronous suspension>

It collects information about available alsa_input devices

Here my snapcraft.yaml config:

snapcraft.yaml
name: mindrecorder
icon: snap/gui/mindrecorder.png
version: '1.0.1'
summary: Open Source Password Manager with Keepass file support.
description: |
  Easily and securely keep track of all your Passwords!

base: core22
adopt-info: mindrecorder
grade: stable
confinement: strict

parts:
  mindrecorder:
    plugin: dump
    source: https://github.com/Roman-Dzerkal/wordcreator/releases/download/1.0/mindrecorder-linux-latest.tar.gz
    override-pull: |
      craftctl default
      craftctl set version=1.0.1
    build-packages:
      - libsecret-1-dev
      - libjsoncpp-dev
    stage-packages:
      - libnotify4
      - libkeybinder-3.0-0
      - libjsoncpp25
      - libsecret-1-0
      - libslang2
      - libayatana-appindicator3-1 
      - libayatana-ido3-0.4-0
      - libvlc-bin 
      - freeglut3
      - libgtk-3-0
      - liblzma5
      - gnome-screenshot
      - ffmpeg 
      - v4l-utils
     

apps:
  mindrecorder:
    command: mindrecorder
    extensions: [ gnome ]
    plugs:
      - camera
      - desktop
      - desktop-legacy
      - home
      - network
      - browser-support
      - process-control
      - screencast-legacy
      - wayland
      - x11

Here permissions in installed app

I had found similar post, but it is not marked as resolved :frowning:

Could you help to resolve this problem please? :pray:

Looks like you are trying to run pactl, is it in your stage-packages? pulseaudio-utils looks like is missing.

pactl is the native system command, not separated package

you need to add the audio-playback plug to get access to the pulse socket of the host and as sergio says, you can not run the pactl command from the host, just add the pulseaudio-utils stage package to have it available in your snap …

EDIT: oh, i see you are calling list sources, assuming you want to actually use the sources you find, that will also require the audio-record plug … note that this one needs to be manually connected after snap installation …

I added these plugs and the stage. That’s working! Now I have new exception:

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: ProcessException: No such file or directory
  Command: killall ffmpeg
#0      _ProcessImpl._start (dart:io-patch/process_patch.dart:401)
#1      Process.start (dart:io-patch/process_patch.dart:38)
#2      _runNonInteractiveProcess (dart:io-patch/process_patch.dart:578)
#3      Process.run (dart:io-patch/process_patch.dart:49)
#4      ScreenRecorder.stopRecord (package:mindrecorder/desktop_view/screen_recorder/screen_recorder.dart:101)
#5      ActionRecorderViewModel.stopRecording (package:mindrecorder/desktop_view/action_recorder/action_recorder_vm.dart:72)
#6      ActionRecorder.build.<anonymous closure>.<anonymous closure> (package:mindrecorder/desktop_view/action_recorder/action_recorder.dart:94)
#7      _InkResponseState.handleTap (package:flutter/src/material/ink_well.dart:1096)
#8      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:253)
#9      TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:627)
#10     BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:306)
#11     BaseTapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:239)
#12     PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:615)
#13     PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:98)
#14     PointerRouter._dispatchEventToRoutes.<anonymous closure> (package:flutter/src/gestures/pointer_router.dart:143)
#15     _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:625)
#16     PointerRouter._dispatchEventToRoutes (package:flutter/src/gestures/pointer_router.dart:141)
#17     PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:127)
#18     GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:460)
#19     GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:440)
#20     RendererBinding.dispatchEvent (package:flutter/src/rendering/binding.dart:336)
#21     GestureBinding._handlePointerEventImmediately (package:flutter/src/gestures/binding.dart:395)
#22     GestureBinding.handlePointerEvent (package:flutter/src/gestures/binding.dart:357)
#23     GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:314)
#24     GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:295)
#25     _invoke1 (dart:ui/hooks.dart:164)
#26     PlatformDispatcher._dispatchPointerDataPacket (dart:ui/platform_dispatcher.dart:361)
#27     _dispatchPointerDataPacket (dart:ui/hooks.dart:91)

As I understand for this needed the process-control plug, but it included

@mmyr just out of interest - what kind of flutter app are you packaging?

i am pretty sure killall is not included in the base snaps, you would have to seed it via adding psmisc to your stage-packages or use pkill instead, that is there by default.

Sorry? What do you mean?

It is working! Thank you a lot of)