Skip to content

fix(github): resolve rename_exe search dir for archives with bin/ subdirectory#8358

Merged
jdx merged 1 commit intomainfrom
fix/rename-exe-bin-dir
Feb 26, 2026
Merged

fix(github): resolve rename_exe search dir for archives with bin/ subdirectory#8358
jdx merged 1 commit intomainfrom
fix/rename-exe-bin-dir

Conversation

@jdx
Copy link
Owner

@jdx jdx commented Feb 26, 2026

Summary

  • When an archive extracts to a bin/ subdirectory layout (e.g., prefix/bin/binary), rename_exe was silently skipped because it searched install_path/ non-recursively instead of install_path/bin/ where the binary actually lives after auto-stripping
  • Now auto-detects the bin/ subdirectory as the search directory for rename_exe, matching the same logic used by discover_bin_paths() for PATH construction
  • Fixes both the GitHub/GitLab/Forgejo backend (static_helpers.rs) and the HTTP backend (http.rs)

Fixes #8354

Test plan

  • Existing e2e/backend/test_http_rename_exe test passes (uses explicit bin_path + strip_components)
  • Manual test with github:sourcemeta/jsonschema using rename_exe = "sm" without explicit bin_path

🤖 Generated with Claude Code


Note

Medium Risk
Touches install/extraction behavior in both the GitHub-style installer helper and the HTTP backend; incorrect directory selection could cause missed or wrong renames on some archive layouts.

Overview
Fixes archive installs where rename_exe previously searched only the extraction root and could silently miss binaries located under an extracted bin/ directory after auto-stripping.

Both the HTTP backend (src/backend/http.rs) and shared archive install path (src/backend/static_helpers.rs) now prefer install_path/bin as the rename_exe search directory when bin_path is not explicitly configured (while keeping explicit bin_path behavior unchanged), and adds an e2e regression test (e2e/backend/test_github_rename_exe) covering this layout.

Written by Cursor Bugbot for commit a9a6ee6. This will update automatically on new commits. Configure here.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @jdx, 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 where the rename_exe option would not function as expected for archives that extract their binaries into a bin/ subdirectory, particularly when a custom bin_path was not specified. The changes introduce intelligent auto-detection of the bin/ subdirectory, ensuring that executables are correctly located and renamed, thereby improving the robustness and usability of archive handling across various backends.

Highlights

  • Rename Executable Logic: The rename_exe functionality now correctly identifies executables located within a bin/ subdirectory when bin_path is not explicitly defined in the configuration. Previously, this would cause rename_exe to silently fail.
  • Bin Directory Auto-Detection: Implemented an auto-detection mechanism for the bin/ subdirectory within the installation path. If install_path/bin/ exists, it is now automatically used as the search directory for rename_exe and bin= options, aligning with discover_bin_paths() logic.
  • Backend Fixes: The fix has been applied to both the HttpBackend (for HTTP-based archives) and the static_helpers (for GitHub/GitLab/Forgejo backends), ensuring consistent behavior across different archive sources.
Changelog
  • src/backend/http.rs
    • Modified the HttpBackend to include logic for auto-detecting a bin/ subdirectory.
    • If bin_path is not provided, the code now checks if dest/bin exists and uses it as the search directory for rename_exe.
  • src/backend/static_helpers.rs
    • Updated the install_artifact function to incorporate bin/ subdirectory auto-detection.
    • When bin_path is not specified, the system now verifies if install_path/bin exists and, if so, uses it as the search_dir for both bin= and rename_exe options.
Activity
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly addresses an issue where rename_exe fails for archives with a bin/ subdirectory by updating the search logic in both http.rs and static_helpers.rs. The changes are functional and resolve the described problem. My main feedback is to refactor the duplicated logic for determining the search directory into a shared helper function to enhance maintainability. I have provided specific suggestions for this refactoring in the comments.

Comment on lines 523 to 533
let search_dir = if let Some(bin_path_template) = lookup_with_fallback(opts, "bin_path") {
let bin_path = template_string(&bin_path_template, tv);
install_path.join(&bin_path)
} else {
install_path.clone()
let bin_dir = install_path.join("bin");
if bin_dir.is_dir() {
bin_dir
} else {
install_path.clone()
}
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This logic for determining the search_dir is also duplicated in src/backend/http.rs. To improve maintainability and avoid code duplication, consider extracting this logic into a new helper function within static_helpers.rs.

For example, you could add this function to static_helpers.rs:

pub fn determine_search_dir(
    base_path: &Path,
    opts: &ToolVersionOptions,
    tv: &ToolVersion,
) -> PathBuf {
    if let Some(bin_path_template) = lookup_with_fallback(opts, "bin_path") {
        let bin_path = template_string(&bin_path_template, tv);
        base_path.join(&bin_path)
    } else {
        let bin_dir = base_path.join("bin");
        if bin_dir.is_dir() {
            bin_dir
        } else {
            base_path.to_path_buf()
        }
    }
}

Then you can replace this block with a call to the new function. I've left a suggestion to use it here, but you'll need to add the function definition yourself.

        let search_dir = determine_search_dir(install_path, opts, tv);

Comment on lines 398 to 408
let search_dir = if let Some(bin_path_template) = get_opt(opts, "bin_path") {
let bin_path = template_string(&bin_path_template, tv);
dest.join(&bin_path)
} else {
dest.to_path_buf()
let bin_dir = dest.join("bin");
if bin_dir.is_dir() {
bin_dir
} else {
dest.to_path_buf()
}
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

As mentioned in the review of src/backend/static_helpers.rs, this logic is duplicated. After creating the determine_search_dir helper function in static_helpers.rs, you can simplify this code as well by replacing this block with a call to the new function. Using the full path crate::backend::static_helpers::determine_search_dir avoids needing to add a use statement.

            let search_dir = crate::backend::static_helpers::determine_search_dir(dest, opts, tv);

@greptile-apps
Copy link

greptile-apps bot commented Feb 26, 2026

Greptile Summary

Fixed rename_exe silently failing when archives extract to bin/ subdirectory layouts. Previously, rename_exe searched the install root non-recursively, missing binaries in auto-stripped bin/ directories. Now auto-detects and searches install_path/bin/ when present, matching the same discovery logic used for PATH construction in discover_bin_paths().

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • Clean bug fix with clear scope, consistent implementation across both affected backends, proper fallback logic, and no breaking changes to existing behavior
  • No files require special attention

Important Files Changed

Filename Overview
src/backend/http.rs Auto-detects bin/ subdirectory for rename_exe when bin_path not explicitly set, matching discover_bin_paths() logic
src/backend/static_helpers.rs Applies same bin/ auto-detection fix for GitHub/GitLab/Forgejo backends, ensuring consistent behavior across all backends

Last reviewed commit: f58108b

@jdx jdx enabled auto-merge (squash) February 26, 2026 11:21
@github-actions
Copy link

github-actions bot commented Feb 26, 2026

Hyperfine Performance

mise x -- echo

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2026.2.21 x -- echo 18.4 ± 0.4 17.2 20.7 1.00
mise x -- echo 18.7 ± 0.6 17.6 26.0 1.02 ± 0.04

mise env

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2026.2.21 env 18.0 ± 0.5 17.1 23.2 1.00
mise env 18.4 ± 0.4 17.4 19.8 1.02 ± 0.04

mise hook-env

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2026.2.21 hook-env 18.5 ± 0.4 17.6 20.3 1.00
mise hook-env 18.7 ± 0.4 17.7 20.7 1.01 ± 0.03

mise ls

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2026.2.21 ls 18.1 ± 0.4 17.2 19.3 1.00
mise ls 18.4 ± 0.4 17.3 20.3 1.02 ± 0.03

xtasks/test/perf

Command mise-2026.2.21 mise Variance
install (cached) 116ms 116ms +0%
ls (cached) 70ms 71ms -1%
bin-paths (cached) 71ms 71ms +0%
task-ls (cached) 695ms 704ms -1%

…directory

When an archive extracts to a bin/ subdirectory layout (e.g.,
prefix/bin/binary), rename_exe was silently skipped because it searched
install_path/ non-recursively instead of install_path/bin/ where the
binary actually lives after auto-stripping.

Now auto-detects the bin/ subdirectory as the search directory for
rename_exe only, matching the same logic used by discover_bin_paths()
for PATH construction. The bin= option continues to use install_path
since its values are already relative to it.

Fixes #8354

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jdx jdx force-pushed the fix/rename-exe-bin-dir branch from f58108b to a9a6ee6 Compare February 26, 2026 11:37
@jdx jdx merged commit a76c353 into main Feb 26, 2026
35 checks passed
@jdx jdx deleted the fix/rename-exe-bin-dir branch February 26, 2026 11:51
mise-en-dev added a commit that referenced this pull request Feb 27, 2026
### 🚀 Features

- add `--outdated` flag to `mise plugins ls` by @jdx in
[#8360](#8360)

### 🐛 Bug Fixes

- **(github)** resolve rename_exe search dir for archives with bin/
subdirectory by @jdx in [#8358](#8358)
- **(install)** skip tools=true env directives during backend
installation by @jdx in [#8356](#8356)
- **(ruby)** resolve correct Windows checksums in lockfile by @jdx in
[#8357](#8357)

### 📦 Registry

- switch terradozer backend to github fork by @chenrui333 in
[#8365](#8365)

### Chore

- **(release)** fix duplicated version prefix in release title by @jdx
in [#8359](#8359)

### New Contributors

- @chenrui333 made their first contribution in
[#8365](#8365)

## 📦 Aqua Registry Updates

#### New Packages (1)

- [`huseyinbabal/taws`](https://github.com/huseyinbabal/taws)

#### Updated Packages (2)

- [`block/goose`](https://github.com/block/goose)
- [`pre-commit/pre-commit`](https://github.com/pre-commit/pre-commit)
risu729 pushed a commit to risu729/mise that referenced this pull request Feb 27, 2026
…directory (jdx#8358)

## Summary
- When an archive extracts to a `bin/` subdirectory layout (e.g.,
`prefix/bin/binary`), `rename_exe` was silently skipped because it
searched `install_path/` non-recursively instead of `install_path/bin/`
where the binary actually lives after auto-stripping
- Now auto-detects the `bin/` subdirectory as the search directory for
`rename_exe`, matching the same logic used by `discover_bin_paths()` for
PATH construction
- Fixes both the GitHub/GitLab/Forgejo backend (`static_helpers.rs`) and
the HTTP backend (`http.rs`)

Fixes jdx#8354

## Test plan
- [ ] Existing `e2e/backend/test_http_rename_exe` test passes (uses
explicit `bin_path` + `strip_components`)
- [ ] Manual test with `github:sourcemeta/jsonschema` using `rename_exe
= "sm"` without explicit `bin_path`

🤖 Generated with [Claude Code](https://claude.com/claude-code)

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Low risk, localized change to post-extraction rename logic; main
impact is that `rename_exe` will now rename binaries in `bin/` layouts
where it previously did nothing.
> 
> **Overview**
> Fixes archive installs where `rename_exe` was applied in the wrong
directory when the extracted archive places binaries under a top-level
`bin/` folder.
> 
> Both the HTTP backend (`http.rs`) and shared installer helper
(`static_helpers.rs`) now auto-select `install_path/bin` (when it
exists) as the search directory when `bin_path` is not explicitly set,
aligning `rename_exe` behavior with PATH discovery.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
f58108b. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
risu729 pushed a commit to risu729/mise that referenced this pull request Feb 27, 2026
### 🚀 Features

- add `--outdated` flag to `mise plugins ls` by @jdx in
[jdx#8360](jdx#8360)

### 🐛 Bug Fixes

- **(github)** resolve rename_exe search dir for archives with bin/
subdirectory by @jdx in [jdx#8358](jdx#8358)
- **(install)** skip tools=true env directives during backend
installation by @jdx in [jdx#8356](jdx#8356)
- **(ruby)** resolve correct Windows checksums in lockfile by @jdx in
[jdx#8357](jdx#8357)

### 📦 Registry

- switch terradozer backend to github fork by @chenrui333 in
[jdx#8365](jdx#8365)

### Chore

- **(release)** fix duplicated version prefix in release title by @jdx
in [jdx#8359](jdx#8359)

### New Contributors

- @chenrui333 made their first contribution in
[jdx#8365](jdx#8365)

## 📦 Aqua Registry Updates

#### New Packages (1)

- [`huseyinbabal/taws`](https://github.com/huseyinbabal/taws)

#### Updated Packages (2)

- [`block/goose`](https://github.com/block/goose)
- [`pre-commit/pre-commit`](https://github.com/pre-commit/pre-commit)
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.

1 participant