Respect $XDG_DATA_HOME#416
Conversation
|
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/schniz/fnm/GvmMFBV4NZo8YbsUVpbTQPwPUAbS |
There was a problem hiding this comment.
Sorry I haven't commented. It's declared as a draft so I ignored it until it's ready to review.
Thanks for the PR!
- I wonder if we should migrate the directories in fnm itself instead of emitting a warning.
- that being said, the installation script installs fnm in
~/.fnmby default, so we might need to warn them to move the binary away, or to do something else. - re: warns multiple times — https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=8caf91cddbb954cccbed08a188d69d42 the real concern is that it will emit the warning on every fnm call 😳 no? (I might be wrong because maybe
fnm envsets theFNM_DIRenv var, which will avoid going into thebase_dir_with_default)
src/config.rs
Outdated
| outln!( | ||
| self#Error, | ||
| "{} {} is deprecated. {} is now the default.", | ||
| "warning:".yellow().bold(), | ||
| "$HOME/.fnm".italic(), | ||
| "$XDG_DATA_HOME/fnm".italic() | ||
| ); |
There was a problem hiding this comment.
Let's use explicit directory paths in the warning so it will work on Windows as well. I think we should have a thorough explanation. Maybe even linking to the issue on GitHub?
warning:
Looks like you have ${legacy} directory on your disk.
fnm is migrating its default storage location from ${modern} to ${legacy}.
Read more about it here: ${GH_ISSUE}
hint:
You can use the following command to move the directory:
mv ${legacy} ${modern}
Please make sure your `fnm` binary is not stored in this directory and if it does, move it to ${A LOCATION WE NEED TO CHOOSE AND UPDATE THE INSTALLATION SCRIPT TO USE AS WELL} and update your shell profile accordingly.
If I'm following, my only concern as a user would be that it takes power away from me. What if I have scripts targeting
Thanks for the REPL example! Not worked with Rust to this extent yet, and when I used it more heavily before I'm pretty sure this site didn't exist. 😄 I agree the unsafe example is more readable and the scope of the unsafety is very limited. I'll go with that approach. |
You are correct. So the real question is whether we should deprecate or use it if it already exists. So:
This way, we don't break, and allow people to install fnm in what do you think? The issue here is less about code and more about how we don't break people. Most people don't care 😃 |
|
I've only really been thinking in terms of application data; for example, my data dir contains only |
|
Probably because XDG is a very niche feature that virtually nobody uses (not passing any judgement on using it, or on the concept itself). Few tools respect XDG vars, and even fewer users expect them to. |
|
Yup. As a Mac user, I really don't expect tools to use the "Application Support" or "Library" directories even though that's the "right place" for them to use |
|
Looking on my Linux machine, it certainly doesn't look accurate to me that "virtually nobody uses [XDG]"; it looks like more than half of my applications favour the standard, and there's generally a push from folks like myself to increase adoption. I believe GHC for example has just implemented support. I'm aware that (I think?) the majority of web devs are on macOS, so I've just opened up my work laptop to have a look at Where would you expect macOS data to go and why? |
|
That suggests more tools support it; it doesn’t speak to whether users set those variables in the first place. Mac GUI applications certainly all follow those conventions; cli tools typically do not. |
|
Okay. Let's step back a bit. Why would you manually delve into the fnm data directory in the first place? My motivation is external in that I want a clean home directory to which end ecosystem support for XDG is helpful. It looks like if users install without a package manager then the default installation directory is Will macOS users even notice if the application data moves? I think that's all my PR would affect. |
Let me give some examples:
So there is no real standard here aside from CLIs usually use what do you think? how does that work out with XDG_? |
|
btw I totally agree with the move (and really thankful for your hard work and communication). most of what I did with using a directory in the home directory was for my convenience and derived from mostly ignorance. Downloading the binary to The config can go into |
|
My understanding of XDG is that This is why I'm questioning what users actually look at in The manually-installed binary is another matter. I can see some talk here and there of an How would we feel about adhering to XDG for application data but leaving the default installation location of the binary alone? I suspect most people who care about XDG are using a package manager anyway; my fnm lives in |
|
I've updated it to only warn once per invocation. I've seen lots of CLI tools warn on each invocation, so that feels okay to me. Edit: Actually that's going to be really annoying if the user has their binary there, they won't be able to silence it... I've also updated the warning. I've omitted the
|
|
I'd be willing to try to pick up this PR if anyone would like me to. I'm always an advocate for using OS-standard directories. |
|
I'm still here and active, but feel free to branch off or otherwise start a separate PR if you think that'd help drive this to completion. I think the main challenge is still figuring out exactly what the behaviour should be rather than the technical implementation thereof. |
|
Oh, alright. Sorry, was kinda just looking through the home folder of my macbook to see if there was anything I could help move to the proper directories. |
|
I understand the concerns and would probably choose to use https://docs.rs/dirs/ if I had deeper thoughts about it. The issue is that it is not the case right now and there are some apps that do the same: My
My
So, I guess we can also say "well, fnm data is not a configuration thing at all", because it is an installation directory. So even if fnm was storing stuff in I did not mind changing the default behavior if it wasn't destructive to users that currently use fnm. People that are saavy enough to care about default directories and to avoid storing data in Sorry if it comes out rude or something, I clearly don't want to be rude. Just stating that this is not as clear and simple as one can think of. I am also not sure that I would have want fnm to store data on That being said, MAYBE we can say:
Lines 85 to 90 in 7e9381c |
|
Sorry for the delayed reply, this notification slipped by me. It's reasonable to want to avoid destructive behaviour for users. It's been a while since I touched this PR, but I think what's here so far aligns with your suggestion. What's left to implement or decide to unblock this? |
|
@samhh I think this approach is good, but let's see if we can remove the |
|
and I am also sorry for dragging this PR for such a long time. I'm showing bad maintainer behavior unfortunately |
|
@Schniz No worries! I appreciate your openmindedness and time on an issue that you're not personally invested in 🙂 I've opted for an |

WIPI have to stop for the evening, but there's one problem left that may be easiest to solve with a better view of the higher-level architecture and/or with more experience with Rust.Becausebase_dir_with_defaultis called twice below, the deprecation notice is printed twice.Do let me know if you have a preferred means of addressing this, else I'll have a crack at it next chance I get.Once the above is addressed this will close #357.