Scripts can no longer be executed from Dolphin

A recent update to KDE seems to have broken some Dolphin actions: I’m now unable to open shell scripts and run them in Konsole. When I right click *.sh files the default action is now to open them in KWrite, instead of opening in a console like before and the way it should be. There is a “Run in Konsole” action however this causes causes a console to pop up with this error instead:

Warning: Could not start program '/home/username/path/script.sh' with arguments '/home/username/path/script.sh'.

Warning: execve: Exec format error

The only way to run scripts any more is to open a console in their directory and do ./script.sh manually. How do I fix scripts in Dolphin please?

I’m sure there was no such default in Manjaro, and the reason why executable *.sh files should not be defaulted to run in any Terminal via click without user consent, is because anyone then can get into running a risky script, intentionally or not.

The default is open a small popup to confirm what you want to do, open - execute or cancel

image

If happens that you checked Do not ask again, then that is the issue. To get that back, go in Dolphin > Configure Dolphin > General > Confirmations
and set to Always ask - or if you prefer to Run script in the options for executable files …

image

Run in Konsole works perfectly fine for me here (stable, testing and unstable), so indeed make sure the script is properly formatted.

1 Like

Clicking directly on the script won’t work either: This does run the script but not in a window… I can see the script’s process but no console is actually spawned for it. That’s why in the past I always had to right-click and choose “open in a console” which is the only one that ran it right.

Yes, that confirmation is defaulted in Dolphin. I disabled always asking since it got annoying for every single shortcut you click on; Most of my scripts are safe anyway, I didn’t create any that could randomly delete stuff or expose private data.

That option works fine for me, with one of my scripts. I use the Right click → Actions → Run in Konsole.

Interesting: I double-checked and it does appear to work with some scripts but not others. Certain scripts work as intended, others give me the error quoted in the first post. I wonder if it might be because this action defaults to the root path and not the current directory where the script resides.

Always use absolute paths in scripts if possible. That way it does not matter where it gets run from.