Support XDG Base Directory Specification
- Database version: Any
- TablePlus version: Any
- Linux distro: Any
- The steps to reproduce this issue:
- Delete
~/.tableplus/if there is one. - Make home directory read only
chmod -222 $HOME. - Launch tableplus.
- Create any connection.
- Restart the app (connection disappeared).
- Delete
Logs:
[~] tableplus
tableplus: /usr/lib/libldap_r-2.4.so.2: no version information available (required by tableplus)
Error: Error creating directory /home/zerdox/.tableplus: Permission denied
Error: Error creating directory /home/zerdox/.tableplus: Permission denied
Error: Error opening file “/home/zerdox/.tableplus/settings/settings.json”: No such file or directory
Error: Error opening file “/home/zerdox/.tableplus/settings/connections.json”: No such file or directory
Error: Error opening file “/home/zerdox/.tableplus/settings/settings.json”: No such file or directory
Error: Error opening file “/home/zerdox/.tableplus/settings/connections.json”: No such file or directory
Error: Error opening file “/home/zerdox/.tableplus/settings/settings.json”: No such file or directory
Error: Error opening file “/home/zerdox/.tableplus/settings/connections.json”: No such file or directory
Expected behaviour:
App stores settings in ~/.config/tableplus/ folder, cache in ~/.cache/tableplus/ folder, etc.
Actual behaviour:
App tries to create it's own dotfolder in my home directory which is disrespectful to user and specifications.
Additional info:
You can learn about XDG spec: here - https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html here - https://wiki.archlinux.org/title/XDG_Base_Directory and here - https://soc.me/standards/defending-home
Fallback also needs to be implemented for legacy path and for older versions.
I can guess .tableplus/settings/settings.json should be located in .config/tableplus/ and .tableplus/settings/connections.json in .local/share/tableplus/.
If you don't want to migrate all users to new path and still want to litter their home directory, just add ability to redefine paths using envs like this (workaround for less and node for example below):
export LESSHISTFILE="$XDG_CACHE_HOME"/less/history
export NODE_REPL_HISTORY="$XDG_DATA_HOME"/node_repl_history
Then I'll add new envs to your app as workaround to this issue.
Thank you!
If envs will be implemented as workaround, do not forget to document them on wiki.
Mac OS X also has it's own specs about files location for example -- https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPFileSystem/Articles/WhereToPutFiles.html