fix(bootstrap): preserve argv[0] for shim dispatch#8521
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a critical issue in Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
52088d8 to
442da75
Compare
There was a problem hiding this comment.
Code Review
This pull request addresses an issue where the original invocation name (argv[0]) was not preserved when using a generated bootstrap script as a symlink. The fix is correct for the file changed. However, the same issue exists in other parts of the codebase that generate scripts. I've added a review comment with suggestions to fix these related issues for consistency, as I am unable to comment on files not included in this pull request's diff.
| }} | ||
| __mise_bootstrap | ||
| exec "$MISE_INSTALL_PATH" "$@" | ||
| exec -a "$0" "$MISE_INSTALL_PATH" "$@" |
There was a problem hiding this comment.
While this change correctly fixes the issue for the bootstrap script, the same problem exists in other script-generating commands. To ensure consistent behavior and fully resolve the argv[0] preservation issue, similar changes are needed in other files.
Since I can only comment on changed files, I'm leaving this feedback here. Please consider applying fixes to the following:
-
src/cli/generate/tool_stub.rs:
In thewrap_with_bootstrapfunction, theexeccall does not preserveargv[0]. It should be changed from:exec "$MISE_BIN" tool-stub "$0" "$@"
to:
exec -a "$0" "$MISE_BIN" tool-stub "$0" "$@"
-
src/cli/generate/task_stubs.rs:
The generated script in thegeneratefunction uses#!/bin/shand anexeccall that doesn't preserveargv[0]. This should be updated to usebashandexec -a.
Change from:#!/bin/sh exec {mise_bin} run {display_name} "$@"
to:
#!/usr/bin/env bash exec -a "$0" {mise_bin} run {display_name} "$@"
There was a problem hiding this comment.
This is out of scope for this PR.
This change is limited to mise generate bootstrap. Other generators should be evaluated separately.
There was a problem hiding this comment.
Correction: this is not the same issue.
This PR is limited to mise generate bootstrap, where preserving argv[0] is required for shim dispatch.
tool_stub.rs passes the original path explicitly to tool-stub, and task_stubs.rs invokes mise run {display_name} directly, so they do not depend on argv[0] in the same way.
a4fec89 to
2089ed5
Compare
07005f2 to
ff67a09
Compare
Greptile SummaryThis PR fixes a one-liner in the generated bootstrap script so that Key points:
Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User as User / Shell
participant Symlink as claude (symlink)
participant Bootstrap as Bootstrap Script ($0="claude")
participant Mise as mise binary
Note over User,Mise: Shim dispatch via symlink (new behaviour)
User->>Symlink: invoke claude
Symlink->>Bootstrap: exec bootstrap ($0 = "claude")
Bootstrap->>Bootstrap: __mise_bootstrap() — install if needed
Bootstrap->>Mise: exec -a "claude" $MISE_INSTALL_PATH "$@"
Note right of Mise: argv[0] == "claude" → shim dispatch works ✓
Note over User,Mise: Direct invocation (unchanged behaviour)
User->>Bootstrap: ./bin/mise install ($0 = "./bin/mise")
Bootstrap->>Bootstrap: __mise_bootstrap() — install if needed
Bootstrap->>Mise: exec -a "./bin/mise" $MISE_INSTALL_PATH "$@"
Note right of Mise: argv[0] == "./bin/mise" → normal mise ✓
Last reviewed commit: "fix(bootstrap): pres..." |
|
coverage-7 failure is unrelated to this PR — caused by Java EA version bump (26 → 27). Fix is tracked in #8634 |
Signed-off-by: tak848 <pairs_char0j@icloud.com>
ff67a09 to
01bce2f
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 01bce2fc3c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| }} | ||
| __mise_bootstrap | ||
| exec "$MISE_INSTALL_PATH" "$@" | ||
| exec -a "$0" "$MISE_INSTALL_PATH" "$@" |
There was a problem hiding this comment.
Preserve absolute argv0 when re-executing bootstrap binary
Using exec -a "$0" "$MISE_INSTALL_PATH" "$@" forwards relative invocation names (for example ./bin/mise) into argv[0]. On Linux, activate intentionally uses ARGV0 as the executable path (src/cli/activate.rs), so eval "$(./bin/mise activate bash)" now emits hooks that call ./bin/mise and those hooks fail after changing directories away from the project root. Before this change, argv[0] was the absolute install path, so the generated activation hooks remained valid across directories.
Useful? React with 👍 / 👎.
upstream PR jdx/mise#8521 で修正されたため、 sed による後処理が不要になった。
…eep・パーミッション追加 (#491) ## Summary - **mise bootstrap**: upstream PR jdx/mise#8521 で `exec -a "$0"` が修正されたため、Taskfile.yaml と mise-bootstrap.yaml の sed ワークアラウンドを削除 - **Claude Code statusline**: rate limit (5h/7d) の使用率表示を追加。Pro/Max サブスクライバー向け、rate_limits が無い場合は非表示 - **Codex config.toml**: experimental 機能 `prevent_idle_sleep` を有効化(実行中のアイドルスリープ防止) - **Claude Code settings**: 不足・推奨パーミッションを追加 - 汎用コマンド: `wc`, `diff`, `file`, `date` - mise: `latest`, `search`, `--version`, `ls`, `current`, `plugins ls` - gh: `issue view`, `search`, `release view`, `pr status`, `repo view` - WebFetch: `docs.anthropic.com`, `docs.devin.ai`, `devin.ai` - MCP: `mcp__devin__read_wiki_contents` ## Test plan - [ ] `task mise:bootstrap` で sed なしに bootstrap スクリプトが正しく生成されることを確認 - [ ] Claude Code statusline で rate limit が表示されることを確認 - [ ] `chezmoi apply` 後に Codex の `/experimental` で prevent_idle_sleep が有効になっていることを確認 - [ ] 追加パーミッションが正しく動作することを確認 (by Claude Code) <!-- devin-review-badge-begin --> --- <a href="https://app.devin.ai/review/tak848/dotfiles/pull/491" target="_blank"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-open-in-devin-review-dark.svg?v=1"> <img src="https://static.devin.ai/assets/gh-open-in-devin-review-light.svg?v=1" alt="Open with Devin"> </picture> </a> <!-- devin-review-badge-end -->
Summary
mise generate bootstrapcurrently emits:That drops the original invocation name.
When the generated bootstrap is used through a shim symlink such as
claude -> /path/to/mise, the final mise process sees the cached binary path asargv[0]instead ofclaude, so shim dispatch breaks.Direct usage of the generated bootstrap as
miseitself should remain unchanged.That direct usage is already documented and expected to work, for example:
This change switches the generated exec line to:
That preserves the shim name when invoked via symlink while still behaving like normal
misewhen the generated script itself is installed asmise.Test plan
./e2e/run_test generate/test_generate_bootstrap./bin/mise versionstill worksexec -a "$0"