FreeCAD / FreeCAD

This is the official source code of FreeCAD, a free and opensource multiplatform 3D parametric modeler.
https://www.freecad.org
Other
19.82k stars 4.06k forks source link

[Problem] Fail to add a simple openscad cube with flatpak version #9423

Open amreo opened 1 year ago

amreo commented 1 year ago

Is there an existing issue for this?

Version

0.20 (Release)

Full version info

[code]
OS: KDE Flatpak runtime (XFCE/xfce)
Word size of FreeCAD: 64-bit
Version: 0.20.2.29603 (Git)
Build type: Release
Branch: (HEAD detached at 0.20.2)
Hash: 930dd9a76203a3260b1e6256c70c1c3cad8c5cb8
Python 3.10.6, Qt 5.15.8, Coin 4.0.0, Vtk 8.2.0, OCC 7.6.3
Locale: Italian/Italy (it_IT)
[/code]

Subproject(s) affected?

OpenSCAD

Problem description

Freecad shows the error "Can't open input file '/var/tmp/fc-00002-510987-000001.scad'!" after I click to add in the add openscad object section. I expect that a cube is added in the 3d view.

Steps to reproduce the bug: 1) open freecad (I have removed /var/config/* before this test) 2) select openscad environment 3) click to "add openscad object" in the toolbar (the button with openscad logo) 4) in the left panel there should be the "add openscad object" section 5) click to add

In the error text should show a text similar to " Can't open input file '/var/tmp/fc-00002-551901-000002.scad'!". I expected to view a cube in the right 3d view

Istantanea_2023-04-28_00-45-59

Anything else?

I use the flatpak version of freecad. I have cleaned the /var/app/config files before the test.

Code of Conduct

adrianinsaval commented 1 year ago

I assume you do have openscad installed through flatpak too? Are you using the built-in openscad wb or the one available in addon manager?

chennes commented 1 year ago

I think with the Flatpak you might have to switch to using the "named pipe" transfer mechanism -- it's in the OpenSCAD WB preferences. Give that a shot and see if it fixes the issue for you.

amreo commented 1 year ago

I assume you do have openscad installed through flatpak too? Are you using the built-in openscad wb or the one available in addon manager?

Yes, openscad is installed inside the flatpak (but I also have installed openscad using 'pacman`)

[amreo@amreo-manjaro-pc ~]$ flatpak run --branch=stable --arch=x86_64 --command=/app/bin/openscad org.freecadweb.FreeCAD  --version
OpenSCAD version 2021.01

Yes, I am using the built-in and default openscad wb, with no customization

amreo commented 1 year ago

I think with the Flatpak you might have to switch to using the "named pipe" transfer mechanism -- it's in the OpenSCAD WB preferences. Give that a shot and see if it fixes the issue for you.

I don't find "named pipe" transfer mechanism in OpenSCAD WB preferences. Allowed options for "Send to OpenSCAD via:" are:

Istantanea_2023-04-29_00-40-27

Anyway using the "stdout pipe" transfer mechanism it works

chennes commented 1 year ago

Yeah, sorry, I wrote the code too long ago, I forgot the name! Yes, the stdout pipe is the one I meant. Glad to hear it works! I have autodetection code for some other packaging types, but I didn't know how to detect running within a Flatpak.

adrianinsaval commented 1 year ago

Could you do me the favor of providing a patch to make that the default @chennes ? I can then apply it while packaging for flatpak

chennes commented 1 year ago

I'm a little hesitant to make it the default since it requires the most recent version of OpenSCAD. Is that available in all of our target distros?

chennes commented 1 year ago

Oh, I see, you meant a literal patch -- what format? git patch or patch?

chennes commented 1 year ago

Here's a git patch OpenSCAD_transfermechanism.patch

adrianinsaval commented 1 year ago

Thank you, a flatpak update that makes this the default option will go live shortly however I notice that when entering the openscad preference page it still shows the first option as default on the dropdown, how may I make it so that the preference page also uses the pipe method as default? Otherwise after entering the preference page and clicking ok it changed back to standard temp directory

adrianinsaval commented 1 year ago

ok we may not actually need to change the default for flatpak, I just checked how we are launching openscad from flatpak and we are giving it permissions to the wrong dir I think: https://github.com/flathub/org.freecadweb.FreeCAD/blob/00927053088318eaf152949971adb53d99728878/openscad.sh#L8 BASEDIR="$XDG_CACHE_HOME/tmp"

instead FreeCAD tries to write to /var/tmp, could you give some pointer on how is freecad determining what directory to use?

chennes commented 1 year ago

It's the "transferdirectory" preference in the OpenSCAD Mod. I don't know where the default comes from, probably something like Python's default temp directory.

luzpaz commented 1 year ago

Any updates on this ?

Knochi commented 3 months ago

Facing the same problem when trying to import certain .csg files. Not all fail but some. Seeing it on 0.21.0 and 0.21.2 Setting the "send to openSCAD via" option to "stdout pipe" gives me a different error. I have openSCAD 2021.1 and also 2024.06.13 (beta) installed via flatpak.

new error:

13:55:45 Recompute failed : difference 13:55:45 obj [] has no Name & Shape 13:55:45 opening /var/tmp/fc-00002-774206-000066.dxf... 13:55:45 There has been an error: 13:55:45 Failed to find any sections! 13:55:45 Traceback (most recent call last): File "/app/freecad/Mod/OpenSCAD/OpenSCADFeatures.py", line 592, in execute shape = OpenSCAD.OpenSCADUtils.process_ObjectsViaOpenSCADShape(fp.Document,fp.Children,\ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/freecad/Mod/OpenSCAD/OpenSCADUtils.py", line 648, in process_ObjectsViaOpenSCADShape return process2D_ObjectsViaOpenSCADShape(children,name,doc) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/freecad/Mod/OpenSCAD/OpenSCADUtils.py", line 590, in process2D_ObjectsViaOpenSCADShape face = importDXFface(tmpfilename,None,None) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/freecad/Mod/OpenSCAD/OpenSCAD2Dgeom.py", line 486, in importDXFface layers = importDXF.processdxf(doc,filename,False,False) or importDXF.layers ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/freecad/Mod/Draft/importDXF.py", line 2147, in processdxf drawing = dxfReader.readDXF(filename) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/deck/.var/app/org.freecadweb.FreeCAD/data/FreeCAD/Macro/dxfReader.py", line 399, in readDXF (infile, drawing) = sm.run((infile, None)) ^^^^^^^^^^^^^^^^^ <class 'TypeError'>: cannot unpack non-iterable bool object 13:55:45 Recompute failed!

luzpaz commented 2 months ago

flatpaks still have an issue with openscad see related: