tiny icon indicating copy to clipboard operation
tiny copied to clipboard

Bad config location on MacOS

Open cyber opened this issue 4 years ago • 7 comments

Installed tiny via: cargo install --git https://github.com/osa1/tiny

$XDG_CONFIG_HOME is set to /Users/name/.config $HOME is set to /Users/name

However when running for the first time:

tiny couldn't find a config file at "/Users/name/Library/Application Support/tiny/config.yml", and created a config file with defaults.

And tiny creates a config file in that location. Subsequent runs will continue to read from that location (env variables still set / config.yml copy-pasted to ~/.config/tiny/config.yml

Why is the config file in this obscure location?

cyber avatar Jan 01 '21 10:01 cyber

$HOME/.tinyrc.yml still works though?

cyber avatar Jan 01 '21 10:01 cyber

On MacOS we use the standard directories. This is done via the dirs crate.

I have no idea if this is ideal or not though, as I'm not a MacOS user. Is this not a standard location on MacOS?

$HOME/.tinyrc.yml still works though?

Yes, but it's deprecated. I'll probably remove it before v1.0.

At the very least we should update the README to mention the standard directories on MacOS. Currently it reads as if we always use XDG_CONFIG_HOME.

osa1 avatar Jan 01 '21 11:01 osa1

Let's keep this open until we at least update the README.

osa1 avatar Jan 01 '21 12:01 osa1

I'll update the readme, but I'm not sure this is considered a fix. I would think that most IRC users are familiar with the UNIX filesystem, and would prefer the option to use XDG_CONFIG_HOME. I can tackle the issue if I get a bit of direction.

SeniorMars avatar Jul 14 '22 22:07 SeniorMars

@KarlWithK It seems that the issue is the dirs crate uses $HOME/Library/Application Support on MacOS, and we are calling this instead of inspecting the actual value of $XDG_CONFIG_HOME or $HOME.

Is that $XDG_CONFIG_HOME value set by you or the current version of MacOS?

See here: https://github.com/osa1/tiny/blob/60363548a089a12f8e5ac912338a4b297a79baf9/crates/tiny/src/config.rs#L152

trevarj avatar Jul 15 '22 06:07 trevarj

I'm not a Mac user myself and I don't know the conventions on macOS, so in the past I trusted dirs to do the right thing on macOS.

I did a quick search. It seems like using ~/.config is common in macOS, but it's not the platform recommendation (1 and 2). Apparently people requested dirs to support ~/.config (or $XDG_CONFIG_PATH) in https://github.com/dirs-dev/directories-rs/issues/47, https://github.com/dirs-dev/dirs-rs/issues/35, and indirectly in downstream issues (see linked issues in directories-rs#47), but the author of dirs doesn't want to add it.

As long as we use the recommended path(s) by default (i.e. $HOME/Library/Application Support on macOS) I'm not opposed to providing a way to override it to a non-standard location.

I say we update the get_config_path function linked by Trevor above to check $XDG_CONFIG_HOME on macOS when a config is not found in the standard location.

osa1 avatar Jul 15 '22 07:07 osa1

847dfff updates README to mention default config path on macOS.

osa1 avatar Dec 12 '22 09:12 osa1