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

This shouldn't use ~/Library/Preferences on macOS #103

Closed
lilyball opened this issue Jan 9, 2020 · 9 comments
Closed

This shouldn't use ~/Library/Preferences on macOS #103

lilyball opened this issue Jan 9, 2020 · 9 comments
Labels

Comments

@lilyball
Copy link

lilyball commented Jan 9, 2020

Describe the bug
After running broot, it wrote out data to a folder ~/Library/Preferences/org.dystroy.broot/. This is very surprising. The ~/Library/Preferences/ folder contains cfprefsd plists, and it's not somewhere that tools should be writing to directly. I'm also surprised to see it doing this at all since this is a command-line application, not a GUI application, and so it should just use the XDG Base Directory Specification locations instead.

If you really want to write to a Mac-like directory, then ~/Library/Application Support/org.dystroy.broot would be the place to use. But I'd really prefer it to just use the XDG dirs instead, e.g. ~/.config/broot/.

To Reproduce
Steps to reproduce the behavior:

  1. Run broot

Expected behavior
Any configuration it writes out should go to a sane location.

Configuration (please complete the following information):

  • OS: macOS 10.15.2 (19C57)
  • Version 0.11.4

Additional context
It looks like this directory is coming from the directories library. Apple's documentation on ~/Library/Preferences very explicitly says you should not be creating your own files in that directory but only using NSUserDefaults or CFPreferences, and that ~/Library/Application Support is the right place to put configuration files. I will be filing an issue against directories as well, but in the meantime broot should switch to using data_dir() instead of config_dir() on macOS.

I'm not sure what the migration path for existing configuration will end up being if directories fixes their code, since you'll need a way to find the old path in order to migrate stuff. Hopefully the directories library can figure this out.

@lilyball
Copy link
Author

lilyball commented Jan 9, 2020

I filed the upstream issue as dirs-dev/directories-rs#62

@Canop
Copy link
Owner

Canop commented Feb 4, 2020

I'm not sure I understand whether there's progress on the soc/directories side. Should I implement the change in broot directly ?

@lilyball
Copy link
Author

lilyball commented Feb 8, 2020

If soc/directories isn't going to update then it would be a good idea to do it here. I hope they're willing to make the change in the library though.

@skoskie
Copy link

skoskie commented Mar 12, 2020

Seconding this issue. I've never seen a CLI tool place prefs in that directory. While I appreciate that there is a standard for placement of these kind of files, and that you adhered to that standard, It appears to me that the XDG standard does itself does not take correct MacOS conventions into account.

Most tools create a hidden directory directly in the user's home folder.

I just did a quick look through my ~/Library/Application Support/ directory and not a single CLI app is represented there. Conversely, configs for all my CLI apps exist directly in my $HOME directory, for example:

$HOME/
  .bashrc
  .gitconfig
  .yarnrc
  .vimrc
  .my.cnf   # MySql
  .oh-my-zsh/
  .iterm2/
  .gem/
  .emacs.d/
  .pip/
  .subversion/
  .vagrant.d/
  .vscode/  # Also exists in L/AS
  .npm/
  .docker/
  .bundle/
  .composer/
  .phpls/

You get the idea. This is just where CLI apps store configs, despite Apple's documentation, which I believe is focused on GUI apps.

To make this more confusing, the standard is a little different when using homebrew, but you might be interested in looking into this method as it may make your life much easier. Homebrew generally keeps all app-related files in a singular app directory (/usr/local/Cellar/<app>/<version> and symlinks the files to default places in the filesystem.

Obviously this is where your bin/broot file resides, but the other standard system-level directories can go in here as well.

@Canop
Copy link
Owner

Canop commented Mar 12, 2020

soc recently made it clear he wasn't favorable to change his library. If somebody has a clean crate to suggest to handle this, I'd prefer not to code it myself

@Canop
Copy link
Owner

Canop commented Jun 22, 2020

Changes were made in the library I use. The right solution for broot seems to be to look first for the new location, then for the second one, and only if both are empty write a new config in the new location. This involves one more lookup at every startup so this would probably be removed at some point between 2050 and 2060.

@Canop Canop added the Mac label Jun 22, 2020
@Canop Canop closed this as completed in 440c136 Jun 22, 2020
@Canop
Copy link
Owner

Canop commented Jun 22, 2020

I don't have a mac for testing. I really need people to confirm it's OK, or tell me it's not, before I can deploy a new release.

You can test the master branch before the release. Don't hesitate to contact me on Miaou if needed.

@kylebebak
Copy link

I know this was already closed, and I have nothing new to say. Just confirming that IMO there shouldn't be a config file for a CLI tool in $HOME/Library/Application\ Support on macOS. As others have noted, config files for almost all CLI tools go directly in $HOME, and are almost always dotfiles

@texastoland
Copy link
Contributor

texastoland commented Dec 27, 2023

Just want to document the current behavior. broot --install adds the script to XDG_CONFIG_HOME as expected with a symlink in the library. The only slightly unexpected behavior was not installing config files until the next run. I specifically ran into it trying to replace them with the latest version. A note in the docs about updating would help. Thanks for making it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants