XDG Base Directory Specification

Info about new community or project announcements, implemented features, classes, modules or APIs. Might get technical!
PLEASE DO NOT POST HELP REQUESTS OR OTHER DISCUSSIONS HERE!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
adrianinsaval
Veteran
Posts: 5541
Joined: Thu Apr 05, 2018 5:15 pm

Re: XDG Base Directory Specification

Post by adrianinsaval »

chennes wrote: Wed Nov 17, 2021 3:28 pm We can't go back in time and fix the fact that the parameter is being written automatically by the Macro dialog, so it always looks to FreeCAD like the user has set a custom directory for this
that's why I say we ignore this parameter in 0.20 and use a new one, if the parameter is something different than the default maybe it could copy the value of the parameter. If 0.20 will keep using the same parameter, can we get a fix for 0.19.3 so it doesn't overwrite the parameter after I fixed it in 0.20? (I'm using a symlink so both versions are using the same config file, once 0.20 is released I would like to just delete the .FreeCAD folder and not have to change the parameter again)
User avatar
onekk
Veteran
Posts: 6144
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: XDG Base Directory Specification

Post by onekk »

Temporary solution would be a warning and a button to move things.

But if you set:

Code: Select all

export FREECAD_USER_HOME="somedir"
As I do to manage different version running on same computer what will happen?

only HOMe/.config/FreeCAD is moved to the desired directory?
data files go to $HOME/.local/share/FreeCAD
mean that /Mod dir where AddOn manager store files are not a subdirectory of FREECAD_USER_HOME?

so If I have more versions, Addon and other things wiil be searched for both (or many versions) in same places?

maybe make also environment variables to manage this thing, (FREECAD_USER_MOD) and maybe (FREECAD_USER_CACHE)?
EDIT:

These lines in the https://github.com/FreeCAD/FreeCAD/comm ... 0c2bc3e27b

Code: Select all

QString configHome = std::get<0>(stdPaths);
QString dataHome = std::get<1>(stdPaths);
QString cacheHome = std::get<2>(stdPaths);

means that there is already such a mechanism, but how could be used?

I could derive that:

FREECAD_USER_HOME >> QString configHome = std::get<0>(stdPaths);

so what are the environment variable names for dataHome and cacheHome?

END EDIT

so a user could use a complete separate "set of directories" to run different versions of FreeCAD, I use ApppImages and doing this I could use stable and dev and sometimes ls3 to check different behaviours.

Hassle of setting three directories instead of one is not very big, as it is a "corner user case", so whatever choice is done to preserve the isolation of different running versions will be a mere problem of knowing what to do.

Losing the ability is the worst case, and I think this has to be avoided, as there were maybe some cases on which an enterprise want to preserve a centralized version of /Mod dir, think of a case when this enterprise is developing his own workbench and want to have same copy running for all the istance of FreeCAD on the entire enterprise (maybe with 20 or more workstation) but have the /Mod/ dir symlinked to a "network shared directory"

Regards

Carlo D.

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/
User avatar
thomas-neemann
Veteran
Posts: 11801
Joined: Wed Jan 22, 2020 6:03 pm
Location: Osnabrück DE 🇩🇪
Contact:

Re: XDG Base Directory Specification

Post by thomas-neemann »

onekk wrote: Wed Nov 17, 2021 4:11 pm ... If I have more versions,..
you could set up a user account in linux for each version
Gruß Dipl.-Ing. (FH) Thomas Neemann

https://www.youtube.com/@thomasneemann5 ... ry=freecad
User avatar
onekk
Veteran
Posts: 6144
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: XDG Base Directory Specification

Post by onekk »

thomas-neemann wrote: Wed Nov 17, 2021 4:22 pm ....
you could set up a user account in linux for each version
But actually all is working perfectly as setting:

FREECAD_USER_HOME will separate all the configuration files for different versions, as Mod and Macro are put into FREECAD_USER_HOME so there is no mix between say a stable and a ls3 version.

see as example:
fc-homdir.png
fc-homdir.png (5.4 KiB) Viewed 5425 times
this is the result of setting: FREECAD_USER_HOME=/home/common/FreeCAD/config-ls3

a .FreeCAD directory is created and also a temp dir is created
fc-homedir2.png
fc-homedir2.png (10.2 KiB) Viewed 5425 times
This is the content of .FreeCAD directory when setting FREECAD_USER_HOME=/home/common/FreeCAD/config-dev

You could note that Macro Mod and AddOnManager are created here plus some other things, like user.cfg and system-cfg this will result in a separation of the Additional WB loaded but also settings like preferences and user configurations.

Regards

Carlo D.
Last edited by onekk on Sat Jul 22, 2023 1:17 pm, edited 1 time in total.
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/
User avatar
adrianinsaval
Veteran
Posts: 5541
Joined: Thu Apr 05, 2018 5:15 pm

Re: XDG Base Directory Specification

Post by adrianinsaval »

I expect setting XDG_CONFIG_HOME XDG_CACHE_HOME XDG_DATA_HOME should give a similar result. See https://wiki.archlinux.org/title/XDG_Ba ... irectories

Are the FreeCAD specific environment variables not working anymore? This wiki page should be updated once this stuff is settled: https://wiki.freecadweb.org/Start_up_an ... _variables
wmayer wrote:
what happens if I set the XDG variables (for example to $HOME/.FreeCAD) mentioned above and FREECAD_USER_HOME (for example to $HOME/freecad020) at the same time? Also, is any of them meaningful on windows?
User avatar
onekk
Veteran
Posts: 6144
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: XDG Base Directory Specification

Post by onekk »

Ok good for my use, only to know how to do.

but

setting XDG_CONFIG_HOME XDG_CACHE_HOME XDG_DATA_HOME will change entire system behaviour.

So having dedicated FreeCAD environment variable like now, it will be a more desirable behaviour.

https://wiki.freecadweb.org/Start_up_an ... _variables

This is only windows centric, at least on the part about "USB portable...." as Linux is using AppImages, maybe some addition for Linux users will be a good job.

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/
User avatar
adrianinsaval
Veteran
Posts: 5541
Joined: Thu Apr 05, 2018 5:15 pm

Re: XDG Base Directory Specification

Post by adrianinsaval »

onekk wrote: Thu Nov 18, 2021 9:07 am Ok good for my use, only to know how to do.

but

setting XDG_CONFIG_HOME XDG_CACHE_HOME XDG_DATA_HOME will change entire system behaviour.

So having dedicated FreeCAD environment variable like now, it will be a more desirable behaviour.

https://wiki.freecadweb.org/Start_up_an ... _variables

This is only windows centric, at least on the part about "USB portable...." as Linux is using AppImages, maybe some addition for Linux users will be a good job.

Regards

Carlo D.
I was under the impression that you were using a script to launch FreeCAD? If so, the variables are set only within the script and don't affect the rest of the system unless you launch other programs within FreeCAD
User avatar
onekk
Veteran
Posts: 6144
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: XDG Base Directory Specification

Post by onekk »

Yes, but as I'm used to do scripting with FreeCAD, and something inside Scripts there are Qt things, if I set "locally" XDG_... also Qt things are affected to the XDG path changes.

Better to have a way to override only FreeCAD directories so FREECAD_USER or Whatever they will be IMHO are better suited to make the job.

If not maybe if you are settings Qt apperance to match say GTK things, as sometimes is done in mixed (GTK and Qt) enviroment you have to copy and mantain different instances of same file.

The main use I do (and I suspect other people do) when changing FRECAD_ environment variable is to "isolate" different copies of FreeCAD running on same machine, maybe for testing purpouses.

Now this "isolation" is working, as expected without changing XDG_.....

I use a different location of .FreeCAD only because I have two different Linux distribution running on my computer and don't want to fiddle with many settings.

Same thing I suspect could happens if you use a "net mounted" directory to uniform maybe /Mod dir across different Workstations in a small business environment, in such case using XDG_.... will maybe more difficult to manage as on different could run different version or same distribution or even different distributions.

But this is only a suspect and not an evidence, as we usually are hoping that FreeCAD will spread his use in some "serious" environment, this is an eventuality to have in mind.

All the above consideration are done IMHO and by a "non professional user".

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/
user1234
Veteran
Posts: 3335
Joined: Mon Jul 11, 2016 5:08 pm

Re: XDG Base Directory Specification

Post by user1234 »

wmayer wrote: Wed Nov 17, 2021 7:12 am Also, if it were configurable the user could map it to /tmp and this IMO can be quite harmful because when the user clicks the "Check now..." button (or the automatic check at start) and the size exceeds the defined limit a dialog comes up where the user can clean the directory. However, in /tmp many other programs put their files there and I don't know what will happen if they got deleted.
You are right, this is a valid point.


wmayer wrote: Wed Nov 17, 2021 7:12 am Further up you wrote that FEM may create huge mesh files. However, these files still will be written to /tmp and not to the cache directory.
Yes, there are extra settings for FEM in the preferences. But it is not about big FEM files only, it is about the dumping the home disk. Anyway, since it is editable in the parameters, it is OK.

Greetings
user1234
wmayer
Founder
Posts: 20243
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: XDG Base Directory Specification

Post by wmayer »

adrianinsaval wrote:IMO this would be best to avoid such unwanted behavior, it's sometimes hard enough to get people to understand how to clear their config, explaining that they might have to do it twice because the old configs got copied over again will be a PITA. I suggest providing macros to migrate config, macros and addon so they are copied at the users discretion. Optional symlink creation to keep configs in sync in case it's desired would be neat too.
The automatic copying of the user.cfg is only planned to be there for short time only and I will remove it soon. I added it to reduce the number of cries if the new version suddenly starts as virgin FreeCAD.

For the long-term migration support a Python script might be useful but migrating the user.cfg this way will be more difficult. This is because you have a running FreeCAD instance when running the Python script and when you only copy the file it will be overridden as soon as the FreeCAD instance is closed. So, what would be additionally needed is to immediately load the user.cfg after copying it but this can cause further problems because of the observers of parameter groups. So for now people have to do the copying manually.
Are the FreeCAD specific environment variables not working anymore?
They still work because they are needed for people who want to run a portable version.
what happens if I set the XDG variables (for example to $HOME/.FreeCAD) mentioned above and FREECAD_USER_HOME (for example to $HOME/freecad020) at the same time?
FREECAD_USER_HOME will override the XDG path. Theoretically you can define the XDG paths to adjust the FreeCAD paths but you must be aware that depending on how you do it you affect other applications that implement the XDG specs.
Also, is any of them meaningful on windows?
I don't think so.
Post Reply