Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App: Fix UserAppData dir on macOS #4620

Closed
wants to merge 1 commit into from

Conversation

pilhuhn
Copy link

@pilhuhn pilhuhn commented Mar 14, 2021

UserAppData dir on macOS is under ~/Library/Preferences/FreeCAD, but should be under ~/Library/Application Support is reserved for entries created by the macOS preferences system.

To migrate from the old behaviour:

$ cd ~/Library/Preferences/
$ mv FreeCAD ../Application\ Support/

Fixes #4596
Forum thread: https://forum.freecadweb.org/viewtopic.php?f=22&t=7104&start=10

@hyarion
Copy link
Contributor

hyarion commented Mar 14, 2021

Thanks for the PR, I agree that we should move it to Application Support.
However, changing the directory without any automated migration will make users lose all their settings, read dialogs, addons, etc and I don't think that is acceptable.

We have the same issue with migration for the readWarning property in PR #2625 and I think we need to put this on hold until we figure out how to solve that issue. I think that we should try to handle this migration the same way.

Btw, could you add a link the forum thread to the PR description?

@pilhuhn
Copy link
Author

pilhuhn commented Mar 14, 2021

In the forum thread, we discussed migration. I fear that migration code adds bloat that needs to basically live forever, as there is no guarantee that a user comes from old-version to new-version via does-the-migration-version.

@hyarion
Copy link
Contributor

hyarion commented Mar 14, 2021

@pilhuhn the migration code (if we where to move the directory) would just need to be a few lines:

# The following code is just psudo code
# The c++ counterpart using boost::filesystem would be similar in length
if not check_exists(user_app_data_path) and check_exists(old_user_app_data_path):
    copy_directory(old_user_app_data_path, user_app_data_path)

I don't understand the argument that it would have to live forever. In my opinion, we just need this migration code for a few versions give users the ability upgrade between versions without too much headache. But I would be fine if we just kept it for one version too if it's perceived as too bloated to keep longer.

You are correct that there will be edge cases where someone tries to upgrade from old-version to new-version without going through the does-the-migration-version, but I don't see why it would be better force everyone to manually upgrade instead of just the edge case users.

@pilhuhn
Copy link
Author

pilhuhn commented Mar 14, 2021

I'll have a look once I find some time.

@yorikvanhavre yorikvanhavre added the ✋ On hold This PR must not be merged before some condition is met label Mar 15, 2021
@yorikvanhavre
Copy link
Member

I marked this PR as "on hold" to prevent it to be merged as is for now...

@hyarion
Copy link
Contributor

hyarion commented Mar 15, 2021

@pilhuhn: I realized that hooking in the migration I requesting wasn't as easy as I thought it was.
I've created a pull request (#4623 ) to make it easier.

@wwmayer
Copy link
Contributor

wwmayer commented Mar 28, 2021

When merging this PR then we should also implement https://tracker.freecadweb.org/view.php?id=2956 where for Linux system the config directory should support XDG

@hyarion
Copy link
Contributor

hyarion commented Mar 29, 2021

@pilhuhn: #4623 is merged now

@yorikvanhavre yorikvanhavre removed the ✋ On hold This PR must not be merged before some condition is met label Mar 30, 2021
@berndhahnebach berndhahnebach added the Core Issue or PR touches core sections (App, Gui, Base) of FreeCAD label Aug 3, 2021
@yorikvanhavre
Copy link
Member

@Hylarion I understand the migration of existing FreeCAD installs was handled by #4623 and this PR is now safe to merge?

@hyarion
Copy link
Contributor

hyarion commented Sep 21, 2021

@yorikvanhavre I would say no. I think it still needs migration (copy config to new location if there aren’t one there already).

@berndhahnebach
Copy link
Contributor

berndhahnebach commented Sep 24, 2021

Following a link to the branch on the CI-repository:

https://gitlab.com/freecad/FreeCAD-CI/-/commits/PR_4620

The CI-status is available on the latest commit of the branch.
If there is no status available the PR should be rebased on latest master.
Check pipeline branches to see if your PR has been run by the CI.

https://gitlab.com/freecad/FreeCAD-CI/-/pipelines?scope=branches

@jbaehr
Copy link
Contributor

jbaehr commented Jan 2, 2022

I think this PR is obsolete now. With commit d86a73f QStandardPaths are used now and with a self-compiled master from Today, I get this:

>>> App.getUserAppDataDir()
'/Users/jonas/Library/Application Support/FreeCAD/'

With an older 0.20.26155 I get /Users/jonas/Library/Preferences/FreeCAD/

The old location still seem to get read, though. At least my custom WBs from /Users/jonas/Library/Preferences/FreeCAD/Mod are in sys.path as well as the new data path.

@wwmayer
Copy link
Contributor

wwmayer commented Jan 3, 2022

No idea how it's possible that sub-directories of /Users/jonas/Library/Preferences/FreeCAD/Mod are in the sys.path.
From QStandardPaths we use the four paths:

  • GenericConfigLocation that points to ~/Library/Preferences on macOS
  • GenericDataLocation that points to ~/Library/Application Support on macOS
  • GenericCacheLocation that points to ~/Library/Caches on macOS
  • TempLocation that apparently is a random path on macOS

The sub-directory for FreeCAD of GenericConfigLocation can be obtained with App.getUserConfigDir() and that of GenericDataLocation with App.getUserAppDataDir().

In the init script sub-directories of App.getUserAppDataDir() are added to the sys.path but I can't see where sub-directories of App.getUserConfigDir() are added. Could it be that in your user.cfg you have set "AdditionalModulePaths"?

@jbaehr
Copy link
Contributor

jbaehr commented Jan 3, 2022

In the init script sub-directories of App.getUserAppDataDir() are added to the sys.path but I can't see where sub-directories of App.getUserConfigDir() are added. Could it be that in your user.cfg you have set "AdditionalModulePaths"?

No, "AdditionalModulePaths" doesn't appear anywhere in /Users/jonas/Library/Preferences/FreeCAD/user.cfg

An older weekly-build app bundle shows this:

>>> App.Version()
['0', '20', '26155 (Git)', '/Users/runner/miniforge3/conda-bld/git_cache/github.com/FreeCAD/FreeCAD master', '2021/10/16 07:23:22', 'master', '0926a4148bcff11249fd4f56bc30256102ffe105']
>>> App.getUserAppDataDir()
'/Users/jonas/Library/Preferences/FreeCAD/'
>>> import sys
>>> for p in sys.path: print(p)
... 
/Users/jonas/Library/Preferences/FreeCAD/Mod/Assembly4
/Applications/FreeCAD.app/Contents/Resources/lib/python3.9/site-packages/git/ext/gitdb
/Users/jonas/Library/Preferences/FreeCAD/Mod/Curves
/Users/jonas/Library/Preferences/FreeCAD/Mod/MakerWorkbench
/Users/jonas/Library/Preferences/FreeCAD/Mod/sheetmetal
/Users/jonas/Library/Preferences/FreeCAD/Mod/fasteners
/Users/jonas/Library/Preferences/FreeCAD/Mod/Manipulator
/Users/jonas/Library/Preferences/FreeCAD/Mod/A2plus
/Users/jonas/Library/Preferences/FreeCAD/Mod/SelectorToolbar
/Users/jonas/Library/Preferences/FreeCAD/Mod/nurbs
/Users/jonas/Library/Preferences/FreeCAD/Mod/BOLTSFC
/Users/jonas/Library/Preferences/FreeCAD/Mod/FCGear
/Users/jonas/Library/Preferences/FreeCAD/Mod/cadquery_module/Libs
/Users/jonas/Library/Preferences/FreeCAD/Mod/cadquery_module/Libs/cadquery
/Users/jonas/Library/Preferences/FreeCAD/Mod/cadquery_module
/Users/jonas/Library/Preferences/FreeCAD/Mod/DynamicData
/Users/jonas/Library/Preferences/FreeCAD/Mod/dodo
/Users/jonas/Library/Preferences/FreeCAD/Mod/ThreadProfile
/Applications/FreeCAD.app/Contents/Resources/Mod/Raytracing
/Applications/FreeCAD.app/Contents/Resources/Mod/Material
/Applications/FreeCAD.app/Contents/Resources/Mod/Import
/Applications/FreeCAD.app/Contents/Resources/Mod/Part
/Applications/FreeCAD.app/Contents/Resources/Mod/Tux
/Applications/FreeCAD.app/Contents/Resources/Mod/PartDesign
/Applications/FreeCAD.app/Contents/Resources/Mod/Measure
/Applications/FreeCAD.app/Contents/Resources/Mod/Points
/Applications/FreeCAD.app/Contents/Resources/Mod/AddonManager
/Applications/FreeCAD.app/Contents/Resources/Mod/Arch
/Applications/FreeCAD.app/Contents/Resources/Mod/Idf
/Applications/FreeCAD.app/Contents/Resources/Mod/Inspection
/Applications/FreeCAD.app/Contents/Resources/Mod/Image
/Applications/FreeCAD.app/Contents/Resources/Mod/Robot
/Applications/FreeCAD.app/Contents/Resources/Mod/Surface
/Applications/FreeCAD.app/Contents/Resources/Mod/OpenSCAD
/Applications/FreeCAD.app/Contents/Resources/Mod/Start
/Applications/FreeCAD.app/Contents/Resources/Mod/Sketcher
/Applications/FreeCAD.app/Contents/Resources/Mod/Show
/Applications/FreeCAD.app/Contents/Resources/Mod/MeshPart
/Applications/FreeCAD.app/Contents/Resources/Mod/Path
/Applications/FreeCAD.app/Contents/Resources/Mod/TechDraw
/Applications/FreeCAD.app/Contents/Resources/Mod/Web
/Applications/FreeCAD.app/Contents/Resources/Mod/Spreadsheet
/Applications/FreeCAD.app/Contents/Resources/Mod/Fem
/Applications/FreeCAD.app/Contents/Resources/Mod/Test
/Applications/FreeCAD.app/Contents/Resources/Mod/Drawing
/Applications/FreeCAD.app/Contents/Resources/Mod/ReverseEngineering
/Applications/FreeCAD.app/Contents/Resources/Mod/Draft
/Applications/FreeCAD.app/Contents/Resources/Mod/Mesh
/Applications/FreeCAD.app/Contents/Resources/Mod
/Applications/FreeCAD.app/Contents/Resources/lib
/Applications/FreeCAD.app/Contents/Resources/Ext
/Applications/FreeCAD.app/Contents/Resources/bin
/Applications/FreeCAD.app/Contents/Resources/lib/python39.zip
/Applications/FreeCAD.app/Contents/Resources/lib/python3.9
/Applications/FreeCAD.app/Contents/Resources/lib/python3.9/lib-dynload
/Applications/FreeCAD.app/Contents/Resources/lib/python3.9/site-packages
/Users/jonas/Library/Preferences/FreeCAD/Mod/cadquery_module/ThirdParty
/Users/jonas/Library/Preferences/FreeCAD
/Applications/FreeCAD.app/Contents/Resources/Macro
/Users/jonas/Library/Application Support/FreeCAD/Mod
/Applications/FreeCAD.app/Contents/Resources/lib/python3.9/site-packages/gitdb/ext/smmap

A recent self-compiled version, started from the build dir, gives this

>>> App.Version()
['0', '20', '26847 (Git)', 'Unknown', '2022/01/02 16:42:18', 'partdesign-helix-taskpanel-tooltips', '30ad918c63df49a24d5f8041ba3683922765b1b3']
>>> App.getUserAppDataDir()
'/Users/jonas/Library/Application Support/FreeCAD/'
>>> import sys
>>> for p in sys.path: print(p)
... 
/Users/jonas/Library/Preferences/FreeCAD/Mod/Assembly4
/Users/jonas/Library/Preferences/FreeCAD/Mod/Curves
/Users/jonas/Library/Preferences/FreeCAD/Mod/MakerWorkbench
/Users/jonas/Library/Preferences/FreeCAD/Mod/sheetmetal
/Users/jonas/Library/Preferences/FreeCAD/Mod/fasteners
/Users/jonas/Library/Preferences/FreeCAD/Mod/Manipulator
/Users/jonas/Library/Preferences/FreeCAD/Mod/A2plus
/Users/jonas/Library/Preferences/FreeCAD/Mod/SelectorToolbar
/Users/jonas/Library/Preferences/FreeCAD/Mod/nurbs
/Users/jonas/Library/Preferences/FreeCAD/Mod/BOLTSFC
/Users/jonas/Library/Preferences/FreeCAD/Mod/FCGear
/Users/jonas/Library/Preferences/FreeCAD/Mod/cadquery_module/Libs
/Users/jonas/Library/Preferences/FreeCAD/Mod/cadquery_module/Libs/cadquery
/Users/jonas/Library/Preferences/FreeCAD/Mod/cadquery_module
/Users/jonas/Library/Preferences/FreeCAD/Mod/DynamicData
/Users/jonas/Library/Preferences/FreeCAD/Mod/dodo
/Users/jonas/Library/Preferences/FreeCAD/Mod/ThreadProfile
/Users/jonas/src/FreeCAD/build/Mod/Raytracing
/Users/jonas/src/FreeCAD/build/Mod/Material
/Users/jonas/src/FreeCAD/build/Mod/Import
/Users/jonas/src/FreeCAD/build/Mod/Part
/Users/jonas/src/FreeCAD/build/Mod/Tux
/Users/jonas/src/FreeCAD/build/Mod/PartDesign
/Users/jonas/src/FreeCAD/build/Mod/Measure
/Users/jonas/src/FreeCAD/build/Mod/Points
/Users/jonas/src/FreeCAD/build/Mod/AddonManager
/Users/jonas/src/FreeCAD/build/Mod/Arch
/Users/jonas/src/FreeCAD/build/Mod/Idf
/Users/jonas/src/FreeCAD/build/Mod/Inspection
/Users/jonas/src/FreeCAD/build/Mod/Image
/Users/jonas/src/FreeCAD/build/Mod/Robot
/Users/jonas/src/FreeCAD/build/Mod/Surface
/Users/jonas/src/FreeCAD/build/Mod/Start
/Users/jonas/src/FreeCAD/build/Mod/Sketcher
/Users/jonas/src/FreeCAD/build/Mod/Show
/Users/jonas/src/FreeCAD/build/Mod/Path
/Users/jonas/src/FreeCAD/build/Mod/TechDraw
/Users/jonas/src/FreeCAD/build/Mod/Web
/Users/jonas/src/FreeCAD/build/Mod/Spreadsheet
/Users/jonas/src/FreeCAD/build/Mod/Test
/Users/jonas/src/FreeCAD/build/Mod/Plot
/Users/jonas/src/FreeCAD/build/Mod/Drawing
/Users/jonas/src/FreeCAD/build/Mod/ReverseEngineering
/Users/jonas/src/FreeCAD/build/Mod/Draft
/Users/jonas/src/FreeCAD/build/Mod/Mesh
/Users/jonas/src/FreeCAD/build/Mod
/Users/jonas/src/FreeCAD/build/lib
/Users/jonas/src/FreeCAD/build/Ext
/Users/jonas/src/FreeCAD/build/bin
/usr/local/opt/python@3.9/Frameworks/Python.framework/Versions/3.9/lib/python39.zip
/usr/local/opt/python@3.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9
/usr/local/opt/python@3.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/lib-dynload
/usr/local/opt/python@3.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages
/usr/local/Cellar/matplotlib/2.1.1/libexec/lib/python3.9/site-packages
/Users/jonas/Library/Preferences/FreeCAD/Mod/cadquery_module/ThirdParty
/Users/jonas/Library/Preferences/FreeCAD
/Users/jonas/src/FreeCAD/build/Macro
/Users/jonas/Library/Application Support/FreeCAD/Mod

@hyarion
Copy link
Contributor

hyarion commented Jan 11, 2022

I also think we can close this.

It was a good suggestion at the time, but the context has changed and the proposed fix, a one liner, is not valid anymore. The original author also seem to have abandoned the pull request.

@pilhuhn
Copy link
Author

pilhuhn commented Jan 11, 2022

@hyarion TBH I did somewhat abandon - partially because I fail to just easily build FC to test any changes.

But if /Users/jonas/Library/Application Support/FreeCAD/Mod is in the search path, then the goal is already achieved and the PR can indeed be closed.

@wwmayer
Copy link
Contributor

wwmayer commented Jan 12, 2022

OK, closing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Core Issue or PR touches core sections (App, Gui, Base) of FreeCAD
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants