What is a shim?
The getting started document says
Volta does not use any fancy OS features or shell-specific hooks. It’s built on the simple, proven approach of shims.
That tells me nothing as I have never heard of shims. (I have been a Unix developer for 30 years so I will be able to understand what it does - as I don't know Rust I can't just read the code to see what it does)
Can you add to the documentation and explanation of what volta does.
@bestlem Thanks for the suggestion! We'll definitely look at updating the docs to improve the description. In the short-term, "shim" here refers to an executable that sits between the command you type and the program you run. For Volta, we install a set of binaries (really they're all symlinks to the same binary, volta-shim) with the names of tools that we manage—node, npm, yarn, etc. We also make sure that the directory where those are installed is first in your PATH.
So when you run e.g. node, the normal OS PATH resolution finds the Volta binary and executes that. Volta then runs through its logic to determine the appropriate version of Node and calls out to that directly.
Does that help clarify the comment in the docs? Happy to dig in more if you have follow-up questions!
@charlespierce Yes thanks for that. I now understand and adding the second paragraph to the documentation as the main part and the first as detail would be good. (The second is the explanation the first and the idea of a him is just detail)
Also the bit which I found really confusing is
Whenever you install a tool with Volta, it adds a shim to your PATH that acts as an intelligent (and fast) router to the right version of the tool and runs it with the right Node engine.
I use conda for python which changes the PATH depending on the environment that it uses. Also many command line tools where you choose which version to use by py putting the directory to the specific directory it is in in your PATH. The wording "it adds a shim to your PATH" made me think volta did the same and altered the PATH to change the route to an executable. From your explanation PATH has nothing to do with the router. The shim executable is the thing that changes the route and you have to add the shim executable to the PATH,
The wording "it adds a shim to your PATH" made me think volta did the same and altered the PATH to change the route to an executable.
Installing a new tool does add a shim to your PATH resolution, but not by modifying the PATH directly. The Volta installer updates your shell profile script (.zshrc, .bashrc, or similar) to add ~/.volta/bin to PATH. Then all of the shims are added to that directory. When you install a new tool, we create a new shim in that directory so that calls to that executable will be automatically routed through the shim.
The way I read that was it altered the PATH each rime you changed the node (or npm) version. Whilst the PATH only needs to be chnaged on installing volta
Ahh, yeah, I can see how that line could read that way. I'll take a look and see if there's a more precise way we could describe how Volta works.
Linking to Wikipedia may help: https://en.wikipedia.org/wiki/Shim_(computing)
@shamrin Yes that might give an overview but I think better to make the documentation describe how this particular project works.
How to automatically switch environments after switching directories? Is this operation done when switching directories? Or is it done when running a specific program like node?