Replace Windows symlinks with volta run scripts#1755
Merged
chriskrycho merged 3 commits intovolta-cli:mainfrom Jul 9, 2024
Merged
Replace Windows symlinks with volta run scripts#1755chriskrycho merged 3 commits intovolta-cli:mainfrom
volta run scripts#1755chriskrycho merged 3 commits intovolta-cli:mainfrom
Conversation
Using symlinks on Windows requires that our users enable Developer mode, which isn't always possible. For directory links, there is an easy solution: NTFS Junctions. These work the same as symlinks but do not require administrator privileges nor developer mode.
Rather than using symlinks, which require administrator privileges or developer mode on Windows, we can instead use small scripts that call out to 'volta run' to actually handle the execution of 3rd party binaries. This also adds a migration to a new v4 layout, which allows Windows installs to migrate immediately to using the script-based shims.
2ddbf4a to
fa04c75
Compare
|
Hey @charlespierce, great work! Did you find time to check how it affects performance? I'd be happy to help if some more work is needed to go forward with it, let me know. |
Contributor
Author
|
Was able to get some testing done, and from what I can tell it doesn't have any major effect on performance, so this should be good to go 🎉 |
chriskrycho
reviewed
Jul 9, 2024
Comment on lines
+95
to
+102
| pub fn shim_file(&self, toolname: &str) -> PathBuf { | ||
| // On Windows, shims are created as `<name>.cmd` since they | ||
| // are thin scripts that use `volta run` to execute the command | ||
| #[cfg(windows)] | ||
| let toolname = format!("{}{}", toolname, ".cmd"); | ||
|
|
||
| path_buf!(self.shim_dir.clone(), toolname) | ||
| } |
Contributor
There was a problem hiding this comment.
For posterity, this is the only difference between the v3 and v4 layouts, and this is the diff:
pub fn shim_file(&self, toolname: &str) -> PathBuf {
- path_buf!(self.shim_dir.clone(), executable(toolname))
+ // On Windows, shims are created as `<name>.cmd` since they
+ // are thin scripts that use `volta run` to execute the command
+ #[cfg(windows)]
+ let toolname = format!("{}{}", toolname, ".cmd");
+
+ path_buf!(self.shim_dir.clone(), toolname)
}
chriskrycho
approved these changes
Jul 9, 2024
alexbestul
added a commit
to alexbestul/windows-dev-docs
that referenced
this pull request
Sep 2, 2025
Developer Mode is no longer required as of volta-cli/volta#1755 and https://github.com/volta-cli/volta/releases/tag/v2.0.0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #1397
Info
volta run <package>.Changes
junctionto create NTFS junctions instead of directory symlinks (this part is directly copied from No more symlinks on Windows #1552)shimmodule to have different implementations ofcreatefor Unix and Windows..cmdscript that callsvolta runfor the shim. It also continues to create a custom Git Bash script, though that script is updated to now callvolta rundirectly, instead of calling the existing shim viacmd.exev4layout since the shim file on Windows is now<binary>.cmdinstead of<binary>.exe.v4that removes and regenerates the shims, making sure that the old symlinks are removed. The migration also updates any existing directory symlinks to use junctions as well.Tested
volta runapproach ⚡