Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update check_shim_reachable to correctly handle Windows #1846

Merged
merged 1 commit into from
Aug 15, 2024

Conversation

charlespierce
Copy link
Contributor

@charlespierce charlespierce commented Aug 15, 2024

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.

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.
@rwjblue rwjblue merged commit 6142614 into volta-cli:main Aug 15, 2024
12 checks passed
@charlespierce charlespierce deleted the check_shim_windows branch August 16, 2024 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

volta install node on Windows incorrectly shows a warning about Node being shadowed
2 participants