Skip to content

Comments

fix(install): skip CurDir components when detecting archive structure#7868

Merged
jdx merged 3 commits intomainfrom
fix/strip-components-curdir
Jan 28, 2026
Merged

fix(install): skip CurDir components when detecting archive structure#7868
jdx merged 3 commits intomainfrom
fix/strip-components-curdir

Conversation

@jdx
Copy link
Owner

@jdx jdx commented Jan 28, 2026

Summary

  • Fix archive extraction for tar/zip files with paths starting with "./" (e.g., ./unison/unison)
  • Skip CurDir (".") components when analyzing archive structure in inspect_tar_contents, inspect_zip_contents, and inspect_7z_contents
  • Prevents incorrect strip_components=1 from being auto-applied to multi-directory archives

Problem

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 applied strip_components=1, flattening the archive contents.

Example from #7862:

  • Archive contains: ./unison/, ./ui/, ./ucm
  • Old behavior extracted: index.html, static/, ucm, unison (flattened)
  • New behavior extracts: ucm, ui/, unison/ (correct structure)

Test plan

  • Existing test_should_strip_components passes
  • Existing test_inspect_tar_contents_logic passes
  • Manual test with unison installation

Fixes #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.

  • Adds skip_curdir_components and applies it in inspect_tar_contents, inspect_zip_contents, and inspect_7z_contents
  • Refines directory detection to check for remaining components after the first non-CurDir
  • Prevents erroneous strip_components=1 on archives with ./-prefixed paths
  • Adds test_inspect_tar_contents_curdir_prefix to cover the ./ case

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

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>
Copilot AI review requested due to automatic review settings January 28, 2026 14:35
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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, and inspect_7z_contents to filter out CurDir components 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
Comment on lines 1053 to 1059
while let Some(c) = components.peek() {
if matches!(c, std::path::Component::CurDir) {
components.next();
} else {
break;
}
}
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
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>
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

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.

@github-actions
Copy link

github-actions bot commented Jan 28, 2026

Hyperfine Performance

mise x -- echo

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>
@jdx jdx enabled auto-merge (squash) January 28, 2026 15:13
@jdx jdx merged commit cd5c953 into main Jan 28, 2026
35 checks passed
@jdx jdx deleted the fix/strip-components-curdir branch January 28, 2026 15:19
mise-en-dev added a commit that referenced this pull request Jan 28, 2026
### 🚀 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)
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