Konsole unexpectedly terminates my Nushell script

Hi! Iโ€™ve written the following script:

#!/usr/bin/env nu

export-env {
    $env.GUM_CHOOSE_SELECTED_FOREGROUND = '#64d633'
}

while true {
    try {
    let response = (gum choose --no-show-help
        --header='What would you like to do?'
        uninstall exit)

    match $response {
        uninstall => {
            try {
                let applications_to_uninstall = (flatpak list --app --columns=application |
                    gum choose --no-limit |
                    str join |
                    split row "\n")
                flatpak uninstall ...$applications_to_uninstall -y
            }
        },
        exit => {
            exit
        }
    }
    } catch {
        exit
    }
}

Which allows me to interactively select required flatpak applications to uninstall them. The issue is that while it executes properly when I simply enter itโ€™s path in Konsole like: /home/emilygraceseville7cf/Documents/programming/mine/nu/application-manager.nu it fails to run the same script with this invocation: flatpak run org.kde.konsole -e /home/emilygraceseville7cf/Documents/programming/mine/nu/application-manager.nu with this output (the window newly opened script Konsole window closes instantly):

kf.config.core: Watching absolute paths is not supported "/usr/share/color-schemes/BreezeLight.colors"
QLayout: Cannot add a null widget to QHBoxLayout/

Whatโ€™s the deal with Konsole in this case? Why does it keep happening?

โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ name            โ”‚ Ubuntu                      โ”‚
โ”‚ os_version      โ”‚ 24.04                       โ”‚
โ”‚ long_os_version โ”‚ Linux (Ubuntu 24.04)        โ”‚
โ”‚ kernel_version  โ”‚ 6.8.0-57-generic            โ”‚
โ”‚ hostname        โ”‚ emilygraceseville7cf-laptop โ”‚
โ”‚ uptime          โ”‚ 1day 31min 6sec             โ”‚
โ”‚ boot_time       โ”‚ a day ago                   โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

For a test Iโ€™ve rewritten this script to Bash:

#!/usr/bin/env bash

export GUM_CHOOSE_SELECTED_FOREGROUND='#64d633'

while true; do
    response="$(gum choose --no-show-help \
        --header='What would you like to do?' \
        uninstall exit)"

    (( $? != 0 )) && break

    case "$response" in
        uninstall)
            applications_to_uninstall="$(flatpak list --app --columns=application | gum choose --no-limit)"
            (( $? != 0 )) && continue

            echo flatpak uninstall $(echo $applications_to_uninstall | tr '\n' ' ') -y
        ;;
        *)
        break
        ;;
    esac
done

but when Iโ€™m trying to execute it like: flatpak run org.kde.konsole -e /home/emilygraceseville7cf/Documents/programming/mine/nu/application-manager-bash.sh I get the following error: Warning: Could not find '/home/emilygraceseville7cf/Documents/programming/mine/nu/application-manager-bash.sh', starting '/bin/bash' instead. Please check your profile settings. It confuses just moreโ€ฆ

The Flatpak permissions might not allow access to the script.

2 Likes

I have enabled the following permissions via Flatseal:

[Context]
shared=network;ipc;
sockets=x11;wayland;session-bus;system-bus;fallback-x11;
devices=dri;all;
features=devel;bluetooth;canbus;per-app-dev-shm;
filesystems=home;host-etc;host-os;xdg-config/kdeglobals:ro;host;

[Session Bus Policy]
com.canonical.AppMenu.Registrar=talk
org.kde.kconfig.notify=talk
org.kde.KGlobalSettings=talk
org.freedesktop.Flatpak=talk
org.kde.kdeconnect=talk

but it didnโ€™t help. Iโ€™m confused: filesystems permission includes home directory AFAIU where my scripts are.

Indeed.

Sorry, that was my best guess.

What else can I provide here to help me with this issue? Iโ€™ve installed Konsole as an apt package and the following command worked perfectly: konsole -e /home/emilygraceseville7cf/Documents/programming/mine/nu/application-manager.nu.

Linked post on Flathub forum is: Issue with inability to launch script via Konsole installed as a flatpak.

Hi - just to check, does the script file itself have the โ€œexecutableโ€ permission set?

It does have an executable flag.