Linux users not being able to use post-processing scripts with transition to Flatpak
 
Notifications
Clear all

Linux users not being able to use post-processing scripts with transition to Flatpak  

  RSS
johnolinda
(@johnolinda)
Active Member
Linux users not being able to use post-processing scripts with transition to Flatpak

Hello! I am sure I am in an extremely small minority, but I am a Linux user who also uses post-processing scripts. With the Flatpak version of PrusaSlicer I am unable to run them since PS is not able to see the entire filesystem or execute arbitrary code. The Appimage version works perfectly. I understand there are packaging issues with Webkit that are probably going to lead to the Appimage being deprecated. Will there be instructions on how to properly configure the Flatpak version to run post-processing scripts?

Posted : 20/10/2024 2:30 am
JimB
 JimB
(@jimb)
Estimable Member
RE: Linux users not being able to use post-processing scripts with transition to Flatpak

Looks like you should be able to run any post-processing script that is in your home directory.  If you want to change the permissions on the flatpak to run the script in other locations.

  • Install Flatseal (com.github.tchx84.Flatseal) and run that.
  • Select PrusaSlicer on the left and then go down to the Filesystem section.
  • Under Other Files, add a new directory, but in path you need.
  • re-start the PrusaSlicer flatpak.

Or via command line

flatpak override -u com.prusa3d.PrusaSlicer --filesystem=/your/path/goes/here

You can remove the -u (user) option and run via sudo to change the system-wide installation instead of the per-user one.

To undo that

flatpak override -u com.prusa3d.PrusaSlicer --nofilesystem=/your/path/goes/here

and to show permissions

flatpak info --show-permissions com.prusa3d.PrusaSlicer
Posted : 20/10/2024 12:45 pm
johnolinda
(@johnolinda)
Active Member
Topic starter answered:
RE: Linux users not being able to use post-processing scripts with transition to Flatpak

When the Perl script is in my home directory I get an Error Code 127 alerting me that the script file cannot be found. I'll update once I've added the script's path explicitly and see if that allows it to run.

Posted : 20/10/2024 5:41 pm
johnolinda
(@johnolinda)
Active Member
Topic starter answered:
RE: Linux users not being able to use post-processing scripts with transition to Flatpak

After reinstalling the Flatpak version, I ran it with the post-processing script stock, as well as with the specific path overrides, and finally with complete system access. Each time I got this result:

In the AppImage version of PrusaSlicer, this works in the same location without any special hoops to jump through. Any recommendations?

Posted : 20/10/2024 8:10 pm
JimB
 JimB
(@jimb)
Estimable Member
RE: Linux users not being able to use post-processing scripts with transition to Flatpak

In my tests, you should be able to run a script with a path relative to the directory you started PrusaSlicer (at least if that is under your home dir).

If you still are having problems, please post what you have for Post-Processing script, the permissions of the script, and the first line of the script.

 

Posted : 20/10/2024 11:01 pm
johnolinda
(@johnolinda)
Active Member
Topic starter answered:
RE: Linux users not being able to use post-processing scripts with transition to Flatpak

The permissions for the script are:

-rwxr-xr-x 1 john domain users   24133 Oct 19 20:44  make_fcp_x3g.pl

and the first line of the script is

#!/usr/bin/perl

I did launch the Flatpak from the same directory as the script without success. However, the Appimage version still works regardless of launch location.

Posted : 21/10/2024 12:08 am
JimB
 JimB
(@jimb)
Estimable Member
RE: Linux users not being able to use post-processing scripts with transition to Flatpak

Well, I duplicated the issue.  You can run a bash script, you can run python, but you can't run perl.  What you are trying to run is begin run in a flatpak sandbox and that does not include perl.  Running

tree $(flatpak info -l org.gnome.Platform//46)/files/bin

will show your the commands available.  Depending on how complicated your perl script is, the easiest might be to convert it to something that is available.

You could mention this on the flatpak related thread on github: https://github.com/prusa3d/PrusaSlicer/issues/13376   Or raise a new issue.  There is a good chance no developer is thinking about perl post-processing scripts and flatpaks.

That said, I did get the PrusaSlicer flatpak to run perl from the Post-Processing script.  But it may be more effort then you want to undertake.  The trick is to move the executable and a library dependency into the home directory and run it from there.  The only thing I had perl do was print a message, so I don't know if anything more extensive will work.  You may end up needing a full install of perl in your home dir.  If you want to give it a try, do something like...

mkdir $HOME/flatpakhack
cp /usr/bin/perl $HOME/flatpakhack
cp /lib/x86_64-linux-gnu/libcrypt.so.1 $HOME/flatpakhack

cat > $HOME/flatpakhack/wrapper <<\EOF
#!/bin/bash
export LD_LIBRARY_PATH=$HOME/flatpakhack
$HOME/flatpakhack/perl $HOME/Development/FFCP-GCodeSnippets/make_fcp_x3g.pl "$@"
EOF

chmod +x $HOME/flatpakhack/wrapper

Then change the PostProcessing script in PrusaSlicer to run the wrapper script: i.e. /home/john/flatpakhack/wrapper

 

Posted : 21/10/2024 2:11 pm
Diem
 Diem
(@diem)
Illustrious Member

Flatpak won't allow anything outside it's box to be run - so perl modules will be blocked - unless you duplicate your whole perl installation on the inside, oh, and if you use Python modules you will have to duplicate that installation too.  Effectively you are handing over control of a large chunk of your machine to the Flatpak distributor - including security updates - the distributors must do them, the updates you install will not protect the Flatpaked bundle...

Cheerio,

Posted : 22/10/2024 12:54 am
johnolinda
(@johnolinda)
Active Member
Topic starter answered:
RE: Linux users not being able to use post-processing scripts with transition to Flatpak

I appreciate your help digging into this, and I've taken your advice and tagged onto the issue on GitHub to see what the devs have to say about it. I'm hoping they're considering post-processing issues before they take the plunge. In the meantime I will keep using the AppImage version, but I think I should probably look at what it would take to port the Perl script over to Bash or Python if they're supported by the Flatpak sandbox.

Posted : 22/10/2024 1:12 am
johnolinda
(@johnolinda)
Active Member
Topic starter answered:
RE: Linux users not being able to use post-processing scripts with transition to Flatpak

OK, so SachCZ over on GitHub weighed in and suggested giving PrusaSlicer access to D-Bus and then using

flatpak-spawn --host /home/john/Development/FFCP-GCodeSnippets/make_fcp_x3g.pl;

to do the post-processing. I enabled the Socket > D-Bus session bus setting, then added

/tmp

to Filesystem > Other files. This allows PrusaSlicer to access the system without giving total access. I'll test this configuration out for a bit and update if there are more issues. 

 

Posted : 26/10/2024 5:47 pm
Share: