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

Use of appdirs yields worse behavior on osx #346

Closed
DanCardin opened this issue Mar 8, 2020 · 8 comments · Fixed by #399
Closed

Use of appdirs yields worse behavior on osx #346

DanCardin opened this issue Mar 8, 2020 · 8 comments · Fixed by #399

Comments

@DanCardin
Copy link

appdirs ignores XDG_CONFIG_HOME on macos and unconditionally wants to put the config in a macos-specific folder location.

Annoyingly there's an appdirs issue which raises this and they just suggest that you artificially set the OS to be linux instead of darwin if you want linux behavior.

I'm going to also comment on their appdirs, but since this affects the behavior of ptpython specifically, i guess for now it'd be ideal for me if ptpython were do something like

if os.environ.get('XDG_CONFIG_HOME') and appdirs.system == 'darwin':
    appdirs.system = 'linux'
@jonathanslenders
Copy link
Member

@carlwgeorge @kitdarko Does any of you have an idea how to fix it?

@carlwgeorge
Copy link
Contributor

appdirs ignores XDG_CONFIG_HOME on macos and unconditionally wants to put the config in a macos-specific folder location.

What you've described sounds like the exact intention of appdirs: use the platform-appropriate directory. While ptpython could choose to allow overriding this behavior by honoring XDG_CONFIG_HOME (part of the XDG Base Directory Specification) on Mac, it would be better if appdirs provided this override themselves.

@DanCardin
Copy link
Author

I agree, there's an ongoing (slow) conversation in appdirs, but it has seemed so far, like the maintainer doesn't seem particularly amenable to the change.

I primarily raised the issue here because the choice to use today's appdirs regresses usability (imo) of ptpython specifically.

I'd be happy to submit a PR on either project if I expected anyone to merge it.

@DanCardin
Copy link
Author

ActiveState/appdirs#78 being the aforementioned issue. The final comment indicating that appdirs appears to be unmaintained (ActiveState/appdirs#79)

I'll also say that the readme is currently incorrect:

It is possible to create a $XDG_CONFIG_HOME/ptpython/config.py file to customize the configuration.

so it's not obvious where i should symlink my config to, as is.

@Julian
Copy link
Contributor

Julian commented Nov 20, 2020

Personally I think the README should be fixed, but do not agree that prompt-toolkit should treat macos like Linux, since the entire point of appdirs is that well, technically, it's correct for these to go in ~/Library/Application Support.

That doesn't mean everyone likes that, or that it's universal to do so. But yeah ptpython should not make that choice.

Instead I think the right solution is ptpython (and any application) should have its own envvar, and that takes precedence over appdirs when set. This way, users like @DanCardin (and indeed myself!) who wish to make macOS match Linux can do so by setting PTPYTHON_CONFIG=$XDG_CONFIG_HOME/ptpython/config.py or wherever they'd like.

Julian added a commit to Julian/dotfiles that referenced this issue Nov 21, 2020
Really this needs to go in Library/ApplicationSupport, so dot will need
modifying, but hopefully prompt-toolkit/ptpython#346 gives me an
envvar to use instead.
Julian added a commit to Julian/ptpython that referenced this issue Nov 21, 2020
In particular allows macOS users to follow the Linux convention
instead of the macOS one, of putting config back in ~/.config.

Closes: prompt-toolkit#346
@Julian
Copy link
Contributor

Julian commented Nov 21, 2020

PR in #399 for the latter way, comments of course welcome.

@DanCardin
Copy link
Author

I mean, I think that any user who is setting XDG_CONFIG_HOME is clearly attempting to opt into the behavior we're talking about. It's not obvious to me why that needs to have any OS significance. At which point the choice of PTPYTHON_CONFIG over XDG_CONFIG_HOME seems kind of arbitrary.

But i'll take what i can get. Any way to opt into a specific location is a win in my book.

jonathanslenders pushed a commit that referenced this issue Dec 3, 2020
In particular allows macOS users to follow the Linux convention
instead of the macOS one, of putting config back in ~/.config.

Closes: #346
@larrybotha
Copy link

Showing my support here for using $XDG_CONFIG_HOME

Something feels weird about appdirs distinction between MacOS and "other Unices":

What directory should your app use for storing user data? If running on macOS, you should use:
~/Library/Application Support/
...
On Linux (and other Unices) the dir, according to the XDG spec, is:
~/.local/share/

Isn't that odd - what is the significance of ~/Library/Application Support for one Unix distro, while other distros should use a spec written for Unix in general? That seems like magic to me.

Adding an environment variable is a small cost, and I appreciate that the addition has been made to allow for setting a config dir, but it does indeed feel dirty.

Using $XDG_CONFIG_HOME could improve UX in a number of areas:

  • Unix-agnostic - switching between distros is trivial
  • "just works" for people who already use XDG paths with other apps
  • no need to set additional env vars

Is this something the maintainers would be interested in considering?

Julian added a commit to Julian/dotfiles that referenced this issue Jun 18, 2022
Really this needs to go in Library/ApplicationSupport, so dot will need
modifying, but hopefully prompt-toolkit/ptpython#346 gives me an
envvar to use instead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants