3

In the apt version of octave, I can use the command octave script.m to execute the file script.m. Similarly flatpak run org.octave.Octave script.m works too.

However, to avoid the long command flatpak run org.octave.Octave, I created a file ~.local/bin/octave with the contents flatpak run org.octave.Octave, and marked it as executable (I already removed the apt version of Octave). While it runs octave just fine, octave script.m does not work anymore, it only opens the command line version of Octave.

I know that I can open Octave and run the script from within, but I am interested to know if the script can be directly run from terminal with the flatpak version of Octave.

Archisman Panigrahi
  • 28,338
  • 18
  • 105
  • 212

2 Answers2

6

Apparently, the trick is to unset the environmental variable SESSION_MANAGER [source].

In order not to interfere with your regular environment, prefer to unset the environment only for the current command using env:

env -u SESSION_MANAGER flatpak run org.octave.Octave script.m

Of course, you can make your life much easier defining for example an alias:

alias octave='env -u SESSION_MANAGER flatpak run org.octave.Octave'

From now on, you can run an octave script as of old:

octave script.m

Include the alias definition in your ~/.bashrc configuration file so it is always available in an interactive terminal.

terdon
  • 100,812
vanadium
  • 88,010
4

I have just installed Octave 6.4.0 from Flatpak on my Ubuntu 20.04.3 LTS system, then rebooted and I'm able to execute my script.m file from terminal from both MATE and GNOME as simple as:

flatpak run org.octave.Octave script.m

Or create a wrapper script by

cat <<'EOF' | tee ~/.local/bin/octave
#!/bin/bash
flatpak run org.octave.Octave "$@"
EOF

chmod +x ~/.local/bin/octave

and call Octave from Flatpak by executing octave script.m. Make sure that ~/.local/bin is defined in your $PATH variable.

Note: make sure that you do not have both deb- and Flatpak-versions of Octave. Remove the first by sudo apt-get autopurge octave if you prefer Flatpak.


If Flatpak fails on your system, you can install Octave 6.4.0 from some PPA by executing below commands:

sudo add-apt-repository ppa:devacom/science
sudo apt-get update
sudo apt-get install octave
muru
  • 197,895
  • 55
  • 485
  • 740
N0rbert
  • 99,918
  • Maybe the reboot was all what was needed. I also installed it specifically for this question, got it to work while in the /home directory, but not after copying the script to another direcrtory (and cd-ing into it). Still, you may see the error Qt: Session management error: None of the authentication protocols specified are supported – vanadium Jan 05 '22 at 12:11