[Solved] TechDraw template issues? (directory needed write permission access)

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
TristanGoss
Posts: 2
Joined: Tue Nov 29, 2022 12:45 pm

[Solved] TechDraw template issues? (directory needed write permission access)

Post by TristanGoss »

Hi there, I hope you can help me? I am using FreeCAD 0.20.1. When in the TechDraw workbench I get the following message when loading the default template or when selecting an alternate template:

"The error message is: Template not set for Page
15:00:18 Traceback (most recent call last):
File "<string>", line 1, in <module>
<class 'OSError'>: Cannot copy file from C:/Program Files/FreeCAD 0.20/data/Mod/TechDraw/Templates/A3_LandscapeTD.svg to /A3_LandscapeTD.svg"

However, if I navigate to C:/Program Files/FreeCAD 0.20/data/Mod/TechDraw/Templates/A3_LandscapeTD.svg the A3_LandscapeTD.svg file is there, and I can open it using Google Chrome.

I thank you in advance, Tristan
Last edited by Kunda1 on Thu Dec 01, 2022 12:44 pm, edited 1 time in total.
Reason: Added note to title thread
User avatar
wandererfan
Veteran
Posts: 6268
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: TechDraw template issues?

Post by wandererfan »

TristanGoss wrote: Tue Nov 29, 2022 1:07 pm "The error message is: Template not set for Page
15:00:18 Traceback (most recent call last):
File "<string>", line 1, in <module>
<class 'OSError'>: Cannot copy file from C:/Program Files/FreeCAD 0.20/data/Mod/TechDraw/Templates/A3_LandscapeTD.svg to /A3_LandscapeTD.svg"
Not sure why it is trying to write to "/", should be writing to a temporary directory. Do you have write permission for the root directory ("/" on current drive)?
Syres
Veteran
Posts: 2893
Joined: Thu Aug 09, 2018 11:14 am

Re: TechDraw template issues?

Post by Syres »

Just to add to wandererfan's question, what is the TMP (not TEMP) environment variable set to using:

Code: Select all

set tmp
at a Command Prompt
TristanGoss
Posts: 2
Joined: Tue Nov 29, 2022 12:45 pm

Re: TechDraw template issues?

Post by TristanGoss »

Thank you, after the IT guys have granted write access the C:\ route directory my problem is solved. Much appreciated!
efferre
Posts: 41
Joined: Tue Jul 03, 2018 12:41 pm

Re: [Solved] TechDraw template issues? (directory needed write permission access)

Post by efferre »

I have found the same problem when using freecad 0.21.0 under Windows. From the python console inside freecad I get

Code: Select all

>>> import os
>>> os.getenv('tmp')
'C:\\Users\\fabio\\AppData\\Local\\Temp'
>>> os.getcwd()
'C:\\Program Files\\FreeCAD 0.21\\bin'
>>> os.chdir('/')
>>> os.getcwd()
'C:\\'
>>> f=open('test.free','w')
Traceback (most recent call last):
  File "<input>", line 1, in <module>
PermissionError: [Errno 13] Permission denied: 'test.free'
But the user can write directly in C:\ outside freecad
efferre
Posts: 41
Joined: Tue Jul 03, 2018 12:41 pm

Re: TechDraw template issues?

Post by efferre »

wandererfan wrote: Tue Nov 29, 2022 1:28 pm
TristanGoss wrote: Tue Nov 29, 2022 1:07 pm "The error message is: Template not set for Page
15:00:18 Traceback (most recent call last):
File "<string>", line 1, in <module>
<class 'OSError'>: Cannot copy file from C:/Program Files/FreeCAD 0.20/data/Mod/TechDraw/Templates/A3_LandscapeTD.svg to /A3_LandscapeTD.svg"
Not sure why it is trying to write to "/", should be writing to a temporary directory. Do you have write permission for the root directory ("/" on current drive)?
As you can see from the previous post, it seems that I am not able to write in "/" from freecad but the user has write access to C:
User avatar
onekk
Veteran
Posts: 6146
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: TechDraw template issues?

Post by onekk »

efferre wrote: Wed Aug 23, 2023 9:02 pm
...
As you can see from the previous post, it seems that I am not able to write in "/" from freecad but the user has write access to C:
On Windows directory permissions have to be managed carefully, you are the user but freecad could result in a different "user" result in the write denial.

There are around if you search as a general problem like "windows directory permissions" ways to check the permissions that could reveal that maybe some permissions are not set correctly.

I'm not a Window expert but the problem is known even in other softwares

Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
efferre
Posts: 41
Joined: Tue Jul 03, 2018 12:41 pm

Re: TechDraw template issues?

Post by efferre »

onekk wrote: Wed Aug 23, 2023 10:22 pm On Windows directory permissions have to be managed carefully, you are the user but freecad could result in a different "user" result in the write denial.

There are around if you search as a general problem like "windows directory permissions" ways to check the permissions that could reveal that maybe some permissions are not set correctly.

I'm not a Window expert but the problem is known even in other softwares

Regards

Carlo D.
I am a Linux user where everything works smoothly :-) Probably there is an issue with permissions but I cannot find a solution. Nothing is written in the docs.

I think the real issue to investigate is why freecad tries to write to "/" instead of

Code: Select all

os.getenv('tmp')
?
Syres
Veteran
Posts: 2893
Joined: Thu Aug 09, 2018 11:14 am

Re: [Solved] TechDraw template issues? (directory needed write permission access)

Post by Syres »

@wandererfan Thinking out loud here, would it be possible to use FileInfo::getTempFileName rather than QTemporaryFile for the Template temp store, or have you been down this rabbit hole previously?
User avatar
wandererfan
Veteran
Posts: 6268
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: [Solved] TechDraw template issues? (directory needed write permission access)

Post by wandererfan »

Syres wrote: Thu Aug 24, 2023 1:06 am Thinking out loud here, would it be possible to use FileInfo::getTempFileName rather than QTemporaryFile for the Template temp store, or have you been down this rabbit hole previously?
AFAIK, the only place TechDraw uses QTemporaryFile is when you press the Export Svg button. From what I can see from the posts, this case doesn't involve Svg Export.

TechDraw does indirectly cause a write to a temporary directory because it uses PropertyFileIncluded for the template file. If PropertyFileIncluded fails to write the temporary file, then the Template would not be created properly, which would cause the "Template not set for Page" message.

I don't think PropertyFileIncluded uses QTemporaryFile, though.
Post Reply