TablePlus-Linux icon indicating copy to clipboard operation
TablePlus-Linux copied to clipboard

Support XDG Base Directory Specification

Open ZerdoX-x opened this issue 4 years ago • 2 comments

  1. Database version: Any
  2. TablePlus version: Any
  3. Linux distro: Any
  4. 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).
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!

ZerdoX-x avatar May 27 '21 15:05 ZerdoX-x

If envs will be implemented as workaround, do not forget to document them on wiki.

ZerdoX-x avatar May 27 '21 15:05 ZerdoX-x

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

ZerdoX-x avatar Nov 15 '21 21:11 ZerdoX-x