-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Be a good citizen on Windows and use appropriate directories. #1124
Comments
This is a naive fix for nodejs#1124. On Windows, files should not be stored directly in `%USERPROFILE%` for a number of reasons. Instead, store the files in an appropriate location on Windows such as `%LOCALAPPDATA%/<vendor>/<product>`.
Any change in the defaults is probably automatically semver-major. That means that even if node-gyp makes the switch, it won't end up on user's systems for a long time. So far no one has complained either so I'd be inclined to leave well enough alone. Changes to the defaults are disruptive to users. Unless there are strongly compelling reasons it's probably not worth doing. |
This is me complaining. 😄
I believe the way I acquired If there is a desire to maintain backward compatibility, I am willing to adjust my naive PR to check first to see if If there is a desire to remove the cruft I can add some code that will cleanup the old location if present and use the new location for everything else. |
I don't mind this change, it bothers me too to see config files in To Ben's point though, it's disruptive because there is a strong assumption in the ecosystem that this is where node-gyp stores and looks for its files. One example is at https://github.com/mafintosh/node-gyp-install which was mainly useful before we had a way of configuring the download source by building it into the binary. Another example would be someone preparing a container or VM image and prepopulating it with required files so it doesn't need to grab things from the internet to do a compile. So, one way to deal with this might be to first check if the required If node-gyp continues to look for files in the old directory then we'd take care of a large class of the concerns around compatibility. |
To make sure I follow your suggestion fully @rvagg, is the idea to do something like this? function fileDoesNotExistsInOldLocation() {
// TODO: check for existence of <homeDir>/.node-gyp/installVersion
}
if (prog.devDir) {
prog.devDir = prog.devDir.replace(/^~/, homeDir)
} else if (process.platform === 'win32' && process.env.LOCALAPPDATA && fileDoesNotExistsInOldLocation()) {
prog.devDir = path.resolve(process.env.LOCALAPPDATA, 'nodejs', 'node-gyp');
} else if (homeDir) {
prog.devDir = path.resolve(homeDir, '.node-gyp')
} else {
throw ...
} Plus some async stuff for reading the file off disk of course. |
tldr; naw, keep throwing stuff in ~/.node-gyp Interesting, I never even really thought about it and I've grown up with windows my whole life. Looking at it now, there's a I don't really feel intruded upon. I put my music in In fact, I recall learning about I'm not a fan of hard to find configurations. I like There's also a file called |
If I understand your argument correctly @snewell92, it is basically (PREFACE: the following paraphrasing is in jest): edgy humor in the fold
While this argument (the non-troll version) does have some merit, I think Node should strive to not contribute to the problem. The reason I call it a problem is because storing large data in Personally, I tend to avoid using any application that dumps stuff in my |
Just an FYI for people who like their IMHO changing the default is something to think about, mostly since the stuff in Anyone wants to submit a PR? We are in [personal opinions] Personally I have a love/hate relationship with my P.S. @MicahZoltu I put your joke in a fold (not so harsh needs to be deleted, but just too colorful to keep as is) :cough: |
Ooh, I didn't know you could do that in GitHub issues. Thanks! |
@MicahZoltu hehe, peeing in the pool xD I have some genuine questions for you Micah, but they aren't necessarily on topic for this issue thread - I've put them in a fold - I can remove them and post them in a more appropriate place if need be. (um... email?.... gitter chat? irc?) Question
How could it break roaming profiles if it is large? And how large? Like 20, 10, 5Gb? Is this because windows can't sync such a large directory? Windows leverages Microsoft's skydrive tech to do that synchronization, which should not be limited by content/size/encoding, right? I still don't share your opinion that apps shouldn't place things in the home directory. If an app places files in there, those are usually files the app intends for me to interact with (configuration/ssh/cache - in this case I can manually download bindings for node-gyp), but really tho, if all these dot files do mess with the roaming profile feature I'll get rid of them, it makes wiping/restoring/upgrading windows so much nicer if I can rely on a set of files moving over. @refack, you asked if anyone wanted to open a PR, but @MicahZoltu opened PR #1125. Are you wanting something different to be opened? |
Sorry, was not aware. Looking at it. |
Having these files dropped into the right location would be a good thing, semver-major or not. I know that it complicates things on the installation side, but changing the default location but giving the user the option to use the old locations would be beneficial. |
Since it's a cache, I'm not convinced on the |
People do it to work around corporate proxies and such, so yes. |
I suspect changing this would break enough things that it'd need to be semver-major. If we're changing it for Windows, it'd be good to respect the XDG spec, I guess by defaulting to |
Re:
(feel free to ping me on Gitter @MicahZoltu if you want to have a more live discussion) |
FWIW, I wrote directories a while ago to provide the correct config, cache, data paths across Linux, BSDs, Windows and macOS. Having such a library for NodeJS would address this issue as well as #175 (and follow rules on macOS, too). Feel free to look at/use the code at https://github.com/soc/directories-rs or https://github.com/soc/directories-jvm. |
Just an FYI that git doesn't pollute (Since it seemed this discussion has been using git as an appeal to authority for where to place files.) |
TL;DR: On Windows, node-gyp should install into
%LOCALAPPDATA%/<vendor>/<product>
.In Linux, the accepted location to store :allthethings: is the home directory (
~
). On Windows, this is not appropriate and almost nothing should go into the root of theUSERPROFILE
directory orHOME
directory. At the moment, node-gyp installs into~
on Windows 10. It should instead install to somewhere more appropriate such as:%APPDATA%/<vendor>/<product>
for small user config of a particular product. Note, this is synced over a network/internet so nothing in here should be particularly large.%LOCALAPPDATA%/<vendor>/<product>
for large user config/extensions/per-user app installs/per-user caching. This folder is not synced over a network/internet so it can be big. Also, it is often redirected to a larger slower drive.%PROGRAMDATA%/<vendor>/<product>
for local (not synced over network) multi-user configuration data. This data is more permissive in that any user can read/write to it unlike%PROGRAMFILES%
which is read only for everyone but admins. Care should be taken with regards to security any executable written here.%PROGRAMFILES%/<vendor>/<product>
for multi-user application data. Only admins can write here, but everyone can read. Good place to put installed software.For the case of
node_gyp
, I assume that%LOCALAPPDATA%/<vendor>/<product>
or%PROGRAMFILES%/<vendor>/<product>
is the appropriate location, depending on whether there is an expectation of admin rights at install time.Note: None of the above folders are
%USERPROFILE%
because the only thing that should use that folder are save dialogs. 😄The text was updated successfully, but these errors were encountered: