Repository navigation
Exec mise wrappers by resolved path, not by name #9583
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
base: quattro
Are you sure you want to change the base?
Changes from 2 commits
9e45f34
23b8366
32a83d9
9f29a48
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,7 +53,16 @@ cat >"$HOME/.local/bin/$command" <<EOF | |
| #!/bin/bash | ||
| export MISE_MINIMUM_RELEASE_AGE=0 | ||
| mise use -g --quiet $package_arg || exit 1 | ||
| exec mise x $package_arg -- $bin_arg "\$@" | ||
|
|
||
| # Resolve the binary to an absolute path. Passing the bare name lets mise | ||
| # re-resolve it through PATH, which can land back on this wrapper and exec | ||
| # forever when ~/.local/bin precedes mise's install dir. | ||
| resolved=\$(mise which $bin_arg 2>/dev/null) | ||
| if [[ -n \$resolved ]]; then | ||
| exec mise x $package_arg -- "\$resolved" "\$@" | ||
| else | ||
| exec mise x $package_arg -- $bin_arg "\$@" | ||
|
Comment on lines
+63
to
+64
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| fi | ||
| EOF | ||
|
|
||
| chmod +x "$HOME/.local/bin/$command" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -71,6 +71,11 @@ if [[ $1 == "where" ]]; then | |
| exit | ||
| fi | ||
|
|
||
| if [[ $1 == "which" ]]; then | ||
| [[ -n ${OMARCHY_TEST_MISE_WHICH:-} ]] && printf '%s\n' "$OMARCHY_TEST_MISE_WHICH" | ||
| exit | ||
| fi | ||
|
|
||
| [[ ${OMARCHY_TEST_MISE_FAIL:-false} != "true" ]] | ||
| SH | ||
|
|
||
|
|
@@ -137,10 +142,29 @@ assert_lazy_stub() { | |
| "$test_home/.local/bin/$command" --version | ||
| mapfile -t mise_calls <"$mise_history" | ||
|
|
||
| [[ ${mise_calls[0]} == "use -g --quiet $package" && ${mise_calls[1]} == "x $package -- $command --version" ]] || | ||
| # The stub resolves the binary to an absolute path before exec'ing it, so the | ||
| # name is never handed back to mise to look up through PATH. | ||
| [[ ${mise_calls[0]} == "use -g --quiet $package" && ${mise_calls[1]} == "which $command" && | ||
| ${mise_calls[2]} == "x $package -- $command --version" ]] || | ||
| fail "$command lazy stub preserves its mise package" | ||
| } | ||
|
|
||
| # A stub must never exec the bare command name when mise can resolve it: with | ||
| # ~/.local/bin ahead of mise's install dir on PATH, the name finds the stub | ||
| # again and it execs itself forever. | ||
| assert_stub_execs_resolved_path() { | ||
| local package=$1 | ||
| local command=$2 | ||
|
|
||
| : >"$mise_history" | ||
| "$ROOT/bin/omarchy-mise-install" "$package" "$command" | ||
| OMARCHY_TEST_MISE_WHICH="/opt/resolved/$command" "$test_home/.local/bin/$command" --version | ||
| mapfile -t mise_calls <"$mise_history" | ||
|
|
||
| [[ ${mise_calls[2]} == "x $package -- /opt/resolved/$command --version" ]] || | ||
| fail "$command lazy stub execs the resolved path, not the bare name" | ||
|
Comment on lines
+167
to
+172
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time! |
||
| } | ||
|
|
||
| assert_lazy_stub "$grok_package" grok | ||
| assert_lazy_stub "$omp_package" omp | ||
| assert_lazy_stub "$crush_package" crush | ||
|
|
@@ -149,6 +173,9 @@ assert_lazy_stub "$cursor_agent_package" cursor-agent | |
| assert_lazy_stub "$muse_package" muse | ||
| pass "custom agent lazy stubs preserve their mise packages" | ||
|
|
||
| assert_stub_execs_resolved_path "$grok_package" grok | ||
| pass "lazy stubs exec the resolved binary path" | ||
|
|
||
| OMARCHY_TEST_MISSING_COMMAND=cursor-agent source "$ROOT/install/user/mise.sh" | ||
| grep -Fx "$agy_package agy" "$stub_log" >/dev/null || fail "user setup creates the Antigravity lazy stub" | ||
| grep -Fx "$grok_package grok" "$stub_log" >/dev/null || fail "user setup creates the Grok lazy stub" | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.