-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
fix(shim): use which_no_shims when resolving mise binary in reshim and doctor #9071
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| # Regression test: when shims are on PATH and a "mise" shim exists (e.g. because | ||
| # core:rust is managed and ~/.cargo/bin contains the mise binary), | ||
| # `mise reshim` should still create shims pointing to the real mise binary, | ||
| # not to the mise shim itself (which would create a circular symlink). | ||
| # Similarly, `mise doctor` should not report shims as missing. | ||
|
|
||
| shimdir="$MISE_DATA_DIR/shims" | ||
| mise_bin="$(which mise)" | ||
|
|
||
| # Install a tool so there are shims to create | ||
| mise i dummy@latest | ||
|
|
||
| # Reshim without shims on PATH — baseline | ||
| mise reshim | ||
|
|
||
| # Verify shim was created and points to the real binary | ||
| assert "readlink $shimdir/dummy" "$mise_bin" | ||
|
|
||
| # Simulate what happens when core:rust is in the toolset: the mise binary | ||
| # itself ends up with a shim because ~/.cargo/bin (containing mise) is scanned | ||
| # as a tool bin directory. Create a mise shim pointing to the real binary. | ||
| ln -sf "$mise_bin" "$shimdir/mise" | ||
|
|
||
| # Now put shims on PATH (as mise activate --shims does in non-interactive shells) | ||
| export PATH="$shimdir:$PATH" | ||
|
|
||
| # Reshim WITH shims on PATH and a mise shim present. | ||
| # Previously this caused file::which("mise") to find the shim, leading to | ||
| # circular symlinks (shim pointing to itself) and broken doctor output. | ||
| mise reshim | ||
|
|
||
| # Shim should still point to the real mise binary, not to the shim directory | ||
| assert "readlink $shimdir/dummy" "$mise_bin" | ||
| assert_not_contains "readlink $shimdir/dummy" "$shimdir" | ||
|
|
||
| # The mise shim itself must not be circular | ||
| if [ -L "$shimdir/mise" ]; then | ||
| assert_not_contains "readlink $shimdir/mise" "$shimdir" | ||
| fi | ||
|
|
||
| # Doctor should not report missing shims | ||
| assert_not_contains "mise doctor" "shims are missing" |
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency with the
reshimimplementation insrc/shims.rs, this path should ideally be absolutized.In
src/shims.rs,mise_binis explicitly absolutized (line 128) before being used to create shims. Ifdoctoruses a different path representation (e.g., a relative path ifwhich_no_shimsfinds one inPATH), the comparison inshims::get_actual_shims(line 436 insrc/shims.rs) might fail when checking if a shim's target matchesmise_bin, potentially leading to false "missing shim" reports in the doctor output.Note that since
analyze_shimsdoes not return aResult, you would need to handle the potential error from an.absolutize()call manually or ensure the path is absolute via other means.