Flutter run process from $SNAP/bin doesn't work

My snapcraft.yaml

Dart doesn’t seem to recognize a snap binary to run. Any ideas?

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: ProcessException: No such file or directory
  Command: qrcp -i wlo1 receive
#0      _ProcessImpl._start (dart:io-patch/process_patch.dart:402)
#1      Process.start (dart:io-patch/process_patch.dart:38)
... ommitted
/snap/qrshare/current/bin$ ls -la
total 14722
drwxr-xr-x  2 root root       27 Feb 12 14:29 .
drwxr-xr-x 10 root root      145 Feb 12 14:29 ..
-rwxr-xr-x  1 root root 15075117 Feb 12 14:27 qrcp

Smells like your app drops the environment… $SNAP/bin is usually in your PATH inside the snap, so the binary should be found

I don’t do any shady things in my application code that’s for sure

Can you run:

snap run --shell qrshare
echo $PATH
whereis qrcp
exit

and let us know the outputs please.

This should drop you into the same environment as your snap runs in but as Bash rather than via your app. As such, if the Bash environment can find it, it makes it likely it’s your app itself causing complications.

Not sure if everything is correct here:

user@hp-laptop:~$ snap run --shell qrshare
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

user@hp-laptop:/home/user$ echo $PATH
/snap/qrshare/5/usr/sbin:/snap/qrshare/5/usr/bin:/snap/qrshare/5/sbin:/snap/qrshare/5/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/qrshare/5/gnome-platform/usr/bin
user@hp-laptop:/home/user$ whereis qrcp
bash: /usr/bin/whereis: Permission denied
user@hp-laptop:/home/user$ sudo whereis
bash: /usr/bin/sudo: Permission denied
user@hp-laptop:/home/user$ su
bash: /usr/bin/su: Permission denied

Tried with sudo and I think now my system is messed up:

user@hp-laptop:~$ sudo snap run --shell qrshare
mkdir: cannot create directory ‘/run/user/0’: Permission denied
root@hp-laptop:/home/user# 

whereis qrcp gives the same error

Can’t run from full path as well:

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: ProcessException: No such file or directory
  Command: /snap/qrshare/13/bin/qrcp -i wlo1 receive