Windows: Use junctions rather than symlinks #519
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
On windows, creating symlinks requires special privileges.
These privileges are typically either assigned by activating windows’s “Developer Mode” or via security policies.
This makes using fnm more difficult for beginners and people on managed machines, where developer mode might not include the right to create symlinks, and local security policies are reset on a regular basis.
NTFS offers an alternative mechanism. Junctions can be created without special privileges.
superuser.com has some more extensive answers on the differences between directory symlinks and junctions. The relevant difference for fnm is that symlinks can work across network drives, whereas junctions only work locally. This shouldn’t matter for fnm’s functionality.
By switching to directory junctions, fnm becomes easier to work with on windows, especially under circumstances where privileges to create symlinks cannot be assigned permanently.
This change is backwards compatible: Since both directory symlinks and junctions are removed using
std::fs::remove_dir
, an fnm upgrade will keep working with existing setups.