Be a good citizen on Windows and use appropriate directories.
See original GitHub issueTL;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 the USERPROFILE
directory or HOME
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. 😄
Issue Analytics
- State:
- Created 7 years ago
- Reactions:10
- Comments:17 (9 by maintainers)
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. 😄
%USERPROFILE%
is the starting point for many user interactions on Windows. When applications likenode-gyp
(and others) throw a bunch of garbage (things end-users don’t ever need to look at/see) into this folder it means that my starting point for all of these user interactions are in the midst of a bunch of garbage I don’t want to see. If I want to play some music I have to sift through piles of “trash” that various applications have decided to dump into%USERPROFILE%
to find myMusic
folder. Same if I want to view some pictures or open a document. Normally my strategy for dealing with bad-acting applications like this is to go find/use an alternative. At the moment, however I’m working on a project that requires Node (and node-gyp) so that isn’t a tenable solution for me this time, hence the Issue submission and PR.I believe the way I acquired
node-gyp
was by doing annpm install
of some project (though it is possible I got it some other way). If the path were to change, wouldn’t it just be re-downloaded to the new location (with cruft left in the old location)? Perhaps there are multiple ways to acquirenode-gyp
that aren’t as auto-magic and won’t self-heal?If there is a desire to maintain backward compatibility, I am willing to adjust my naive PR to check first to see if
.node-gyp
exists in%USERPROFILE%
and if it does set that to thedev-dir
and if not then set the correct path todev-dir
. Then on the next major version bump the fallback code can be removed.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.