GeezerVison is showing github.com — Update `check_shim_reachable` to correctly handle Windows by charlespierce · Pull Request #1846 · volta-cli/volta
Conversation
Closes #1845
Info
We have a helper utility check_shim_reachable that notifies the user if the shim for a tool they just installed is on their PATH and whether it's shadowed. However, that check currently assumes that all shims are in VoltaHome::shim_dir. Unfortunately, on Windows that isn't the case—we install the default shims alongside Volta itself inside of Program Files.
To prevent showing an unnecessary message to Windows users, we should properly check both Volta directories on Windows when validating whether a shim is properly available on the Path.
Changes
- Updated
check_shim_reachable to call a new function find_expected_shim_dir to determine which directory should be used as the base when checking for the shim.
- Implemented
find_expected_shim_dir for both Unix and Windows;
- On Unix it always returns the shim directory inside of
VOLTA_HOME, because all of the shims are installed there, even the default ones.
- On Windows, it first checks the
VOLTA_HOME shim directory, and if the shim isn't found there, it defaults to the VoltaInstall root directory, which should be where Volta itself is installed.
- Also updated the check to use
starts_with rather than a pure equality to determine if the resolved binary matches the expectation or not.
Tested
- Ran locally on Windows and validated that the note about shadowing doesn't show incorrectly.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
We have a helper utility `check_shim_reachable` that notifies the user if the shim
for a tool they just installed is on their PATH and whether it's shadowed. However,
that check currently assumes that all shims are in `VoltaHome::shim_dir`. Unfortunately,
on Windows that isn't the case—we install the default shims alongside Volta itself
inside of `Program Files`.
To prevent showing an unnecessary message to Windows users, we should properly check
both Volta directories on Windows when validating whether a shim is properly available
on the Path.
Reviewers
rwjblue
rwjblue approved these changes
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
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.