fix(install): skip CurDir components when detecting archive structure#7868
fix(install): skip CurDir components when detecting archive structure#7868
Conversation
When tar/zip archives have paths starting with "./" (e.g., "./unison/unison"),
the inspect_*_contents functions incorrectly identified "." as the only
top-level directory. This caused should_strip_components() to return true,
incorrectly applying strip_components=1 and flattening the archive contents.
The fix skips CurDir (".") components when analyzing archive structure,
so archives with multiple top-level directories are correctly detected.
Fixes #7862
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug in archive extraction where files with paths starting with "./" were incorrectly flattened during extraction. The fix modifies three archive inspection functions to skip CurDir (".") components when determining the archive structure, preventing incorrect application of strip_components=1.
Changes:
- Modified
inspect_tar_contents,inspect_zip_contents, andinspect_7z_contentsto filter outCurDircomponents before analyzing archive structure - Updated directory detection logic to check remaining components after filtering instead of total component count
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/file.rs
Outdated
| while let Some(c) = components.peek() { | ||
| if matches!(c, std::path::Component::CurDir) { | ||
| components.next(); | ||
| } else { | ||
| break; | ||
| } | ||
| } |
There was a problem hiding this comment.
This CurDir-skipping logic is duplicated across three functions (inspect_tar_contents, inspect_zip_contents, and inspect_7z_contents). Consider extracting it into a helper function to reduce code duplication and improve maintainability.
Adds a test that creates a real tar.gz archive with "./" prefixed paths and verifies that inspect_tar_contents correctly identifies the actual top-level entries (dir1, dir2, standalone) instead of just ".". Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
Hyperfine Performance
|
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2026.1.8 x -- echo |
19.7 ± 0.3 | 19.0 | 21.6 | 1.00 |
mise x -- echo |
20.3 ± 0.4 | 19.5 | 21.9 | 1.03 ± 0.03 |
mise env
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2026.1.8 env |
19.2 ± 0.6 | 18.4 | 25.1 | 1.00 |
mise env |
19.7 ± 0.4 | 18.8 | 21.3 | 1.03 ± 0.04 |
mise hook-env
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2026.1.8 hook-env |
19.5 ± 0.4 | 18.8 | 22.5 | 1.00 |
mise hook-env |
19.9 ± 0.4 | 19.2 | 21.9 | 1.02 ± 0.03 |
mise ls
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2026.1.8 ls |
17.3 ± 0.3 | 16.7 | 18.7 | 1.00 |
mise ls |
17.8 ± 0.3 | 17.1 | 19.2 | 1.03 ± 0.03 |
xtasks/test/perf
| Command | mise-2026.1.8 | mise | Variance |
|---|---|---|---|
| install (cached) | 110ms | 111ms | +0% |
| ls (cached) | 67ms | 67ms | +0% |
| bin-paths (cached) | 71ms | 71ms | +0% |
| task-ls (cached) | 4243ms | ✅ 292ms | +1353% |
✅ Performance improvement: task-ls cached is 1353%
Addresses PR feedback to reduce code duplication. The CurDir-skipping logic was duplicated across inspect_tar_contents, inspect_zip_contents, and inspect_7z_contents. Now extracted into a single helper function. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
### 🚀 Features - **(doctor)** add backend mismatch warnings by @jdx in [#7847](#7847) - **(http)** add rename_exe support for archive extraction by @jdx in [#7874](#7874) - **(http)** send x-mise-ci header for CI environment tracking by @jdx in [#7875](#7875) - **(install)** auto-install plugins from [plugins] config section by @jdx in [#7856](#7856) - **(registry)** add vercel by @mikecurtis in [#7844](#7844) - **(task)** support glob patterns in task_config.includes by @jdx in [#7870](#7870) - **(task)** add task templates for reusable task definitions by @jdx in [#7873](#7873) ### 🐛 Bug Fixes - **(backend)** change registry mismatch log from info to debug by @jdx in [#7858](#7858) - **(ci)** use squash merge for auto-merge-release workflow by @jdx in [7e5e71e](7e5e71e) - **(ci)** remove --auto flag to merge immediately when CI passes by @jdx in [23ed2ed](23ed2ed) - **(github)** select platform-matching provenance file for SLSA verification by @jdx in [#7853](#7853) - **(go)** filter out version "1" from available versions by @jdx in [#7871](#7871) - **(install)** skip CurDir components when detecting archive structure by @jdx in [#7868](#7868) - **(pipx)** ensure Python minor version symlink exists for postinstall hooks by @jdx in [#7869](#7869) - **(registry)** prevent duplicate -stable suffix in Flutter download URLs by @jdx in [#7872](#7872) - **(task)** pass env to usage parser for env-backed arguments by @jdx in [#7848](#7848) - **(task)** propagate MISE_ENV to child tasks when using -E flag by @jdx in [06ee776](06ee776) - **(vfox-dotnet)** use os.execute() to fix Windows installation by @prodrigues1912 in [#7843](#7843) ### 📚 Documentation - update cache-behavior with env_cache information by @jdx in [#7849](#7849) ###◀️ Revert - remove task inheritance from parent configs in monorepos by @jdx in [#7851](#7851) - Revert "fix(ci): remove --auto flag to merge immediately when CI passes" by @jdx in [0606187](0606187) ### 📦 Registry - add mago ([aqua:carthage-software/mago](https://github.com/carthage-software/mago)) by @scop in [#7845](#7845) ### Chore - **(ci)** auto-merge release branch into main daily at 4am CST by @jdx in [#7852](#7852) ### New Contributors - @mikecurtis made their first contribution in [#7844](#7844) - @prodrigues1912 made their first contribution in [#7843](#7843)
Summary
./unison/unison)CurDir(".") components when analyzing archive structure ininspect_tar_contents,inspect_zip_contents, andinspect_7z_contentsstrip_components=1from being auto-applied to multi-directory archivesProblem
When archives have paths like
./unison/unison,./ui/index.html, the first path component is.(CurDir). The previous code saw this as a single top-level directory and incorrectly appliedstrip_components=1, flattening the archive contents.Example from #7862:
./unison/,./ui/,./ucmindex.html,static/,ucm,unison(flattened)ucm,ui/,unison/(correct structure)Test plan
test_should_strip_componentspassestest_inspect_tar_contents_logicpassesFixes #7862
🤖 Generated with Claude Code
Note
Corrects archive inspection to ignore leading
.path components (e.g.,./dir/file) so multi-entry archives are detected accurately.skip_curdir_componentsand applies it ininspect_tar_contents,inspect_zip_contents, andinspect_7z_contentsCurDirstrip_components=1on archives with./-prefixed pathstest_inspect_tar_contents_curdir_prefixto cover the./caseWritten by Cursor Bugbot for commit c14b1b3. This will update automatically on new commits. Configure here.