Permission denied on launch (sh script)

I builded snap package, but after the launch, I rejected the error:

/snap/soundband/x1/bin/desktop-launch: line 478: /snap/soundband/x1/AppRun.sh: Permission denied
/snap/soundband/x1/bin/desktop-launch: line 478: exec: /snap/soundband/x1/AppRun.sh: cannot execute: Permission denied

my snapcraft.yaml

name: soundband
version: '1.0'
summary: Mobile and desktop song sync audio player. working on wifi. 
description: |
  SoundBand is a cross-platform application for synchronous music playback on all your devices. supported platform:
    Linux
    Android
    Windows


grade: stable # must be 'stable' to release into candidate/stable channels
confinement: strict # use 'strict' once you have the right plugs and slots


icon: data/icons/icon.png

apps:
  soundband:
    command: desktop-launch $SNAP/AppRun.sh

    plugs: [desktop, unity7, home, opengl, x11, wayland, gsettings, pulseaudio, alsa]

parts:
  soundband:
    plugin: dump
    source: data/

    after: [desktop-qt5]

You have to add the executable bit to the script in order to make it well…executable.

-rwx------ 1 andrei andrei 280 Жнв 22 10:36 AppRun.sh*

Have you added a shebang to the script’s beginning?

yes
my script

#!/bin/sh
BASEDIR=$(dirname $0)
export LD_LIBRARY_PATH="$BASEDIR/lib:$BASEDIR"
export QML_IMPORT_PATH="$BASEDIR/qml"
export QML2_IMPORT_PATH="$BASEDIR/qml"
export QT_PLUGIN_PATH="$BASEDIR/plugins"
export QT_QPA_PLATFORM_PLUGIN_PATH="$BASEDIR/plugins/platforms"
$BASEDIR//SoundBand

Do you have any apparmor denials. You can get the list by running: dmesg | grep DENIED

Not exactly sure, but you should try to replace it with #!/usr/bin/env sh

changed but not really helped,

andrei@E2:/snap/soundband/x1$ ll
итого 346
drwxrwxr-x 12 root root    341 Жнв 22 11:45 ./
drwxr-xr-x  3 root root   4096 Жнв 22 12:13 ../
-rwx--x--x  1 root root    289 Жнв 22 11:38 AppRun.sh*
drwxr-xr-x  2 root root     37 Жнв 22 11:43 bin/
-rwxr-xr-x  1 root root    499 Жнв 22 11:45 command-soundband.wrapper*
drwxr-xr-x 11 root root    189 Жнв 22 11:43 etc/
-rw-r--r--  1 root root     13 Жнв 22 11:42 flavor-select
drwxrwxr-x  2 root root     31 Жнв 22 11:44 icons/
drwxrwxr-x  4 root root    536 Жнв 22 11:44 lib/
lrwxrwxrwx  1 root root     16 Жнв 22 10:36 libSync.so -> libSync.so.1.0.0*
lrwxrwxrwx  1 root root     16 Жнв 22 10:36 libSync.so.1 -> libSync.so.1.0.0*
lrwxrwxrwx  1 root root     16 Жнв 22 10:36 libSync.so.1.0 -> libSync.so.1.0.0*
-rwxrwxr-x  1 root root 225264 Жнв 22 10:36 libSync.so.1.0.0*
drwxrwxr-x  3 root root     43 Жнв 22 11:45 meta/
drwxrwxr-x 10 root root    170 Жнв 22 11:44 plugins/
drwxrwxr-x 20 root root    369 Жнв 22 11:44 qml/
drwxrwxr-x  3 root root     26 Жнв 22 11:45 snap/
-rwxrwxr-x  1 root root 123240 Жнв 22 10:36 SoundBand*
drwxr-xr-x  7 root root    101 Жнв 22 11:43 usr/
drwxr-xr-x  3 root root     26 Сак 25  2016 var/


sh: 0: Can't open /snap/soundband/x1/AppRun.sh

#!/usr/bin/env sh
BASEDIR=$(dirname $0)
export LD_LIBRARY_PATH="$BASEDIR/lib:$BASEDIR"
export QML_IMPORT_PATH="$BASEDIR/qml"
export QML2_IMPORT_PATH="$BASEDIR/qml"
export QT_PLUGIN_PATH="$BASEDIR/plugins"
export QT_QPA_PLATFORM_PLUGIN_PATH="$BASEDIR/plugins/platforms"
$BASEDIR//SoundBand

As the script is owned as root but the snap is run as your identity, you should add the r permission to others (755 is a sane value as well)

these are different, and both wrong: I think the first one is from your build and the second from the snap itself.

In general, scripts need user, group and world read and execute bits set to work properly. chmod a+rx.

3 Likes