Skip to content

Leave Shims on the PATH when executing a tool #492

@charlespierce

Description

@charlespierce

Currently, when we build the PATH to execute a tool, we remove the ~/.volta/bin shim directory from the path, then prepend the relevant node and yarn directories. This allows a command like node to run and pick up the correct version of the node executable.

However, removing the shim directory means that any tool that is executed is not able to access other tools (except for node, npm, and yarn that are added to the path). This causes issues when two tools are designed to interoperate, such as bower and bower-away. The tools are both installed "globally", but when running one, you can't access the other.

Instead, we should leave the shim directory on the path, but make sure that the node and yarn directories are added first. This will allow a command like node index.js to still resolve to the correct version of Node (and not the shim), but will also let any tool see any other global tool that is installed (through the shim).

This has some risks: If we call node and for some reason the node executable isn't where we expect it, the call could come back to the shim, which will then try again, and again, until the OS kills the recursion. This shouldn't happen unless someone manually deletes the file, and if it does, it's a bug, but we might want to investigate if it's possible to detect a recursive call like that and break out early.

Another issue with tools calling each other is they'll each be adding their platform to the path, so it's possible that we wind up creating a merged platform that we didn't expect, or running into size limits on the length of the PATH, but I think those problems are fairly low-impact.

@dherman @chriskrycho @rwjblue Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions