Skip to content

fix: Windows で通知や報告に出すパスから \\?\ を外す - #137

Merged
owayo merged 1 commit into
mainfrom
fix/issue-126-display-paths-without-verbatim
Nov 6, 2026
Merged

owayo merged 1 commit into
mainfrom
fix/issue-126-display-paths-without-verbatim

Conversation

@owayo

@owayo owayo commented Nov 6, 2026

Copy link
Copy Markdown
Owner

概要

Windows で、depup が利用者に見せるメッセージのファイルのパスに、拡張長パスの接頭辞 \\?\ が付いていました。ルートに minimumReleaseAge を持つ pnpm workspace で depup --age 2w --dry-run を実行すると (10 days from \\?\C:\work\app\pnpm-workspace.yaml) のように表示され、install の復元の報告 (recovery failed for \\?\C:\...\Cargo.lock: ...) も同じ形になっていました。表示では接頭辞を外します。

原因

std::fs::canonicalize は Windows で \\?\ 付きのパス (verbatim path) を返します。age の設定の出どころ (orchestrator/age.rs) や install の復元の報告 (install/transaction.rs の RollbackReport::print) は、正規化したパスをそのまま display() で表示していました。cargo_rollback/scratch.rs には同じ接頭辞を外す strip_verbatim_prefix がありましたが、表示の側では使っていませんでした。

変更内容

  • user_path モジュールを足し、strip_verbatim_prefix を cargo_rollback から移して共有する。利用者に見せるパスは for_display で \\?\ を外して表示する (\\?\C:\... は C:\...、\\?\UNC\server\share\... は \\server\share\...)。
  • age の設定の通知と、install の復元の報告 (Scope・restored・removed・recovery failed・kept・写しの場所) で for_display を使う。
  • AGENTS.md に書いた。

ファイルの操作と比較には元のパスを使います。正規化の結果そのものから接頭辞を外すと、長いパス (\\?\ がないと開けないことがある) の操作に影響するためです。この PR は #108 (通知を 1 回だけ出す) の変更の上に作っています。

検証

  • 回帰テスト (修正前のコードでは失敗することを確認済み): orchestrator::tests::age_notices_show_paths_without_the_verbatim_prefix (age の通知の設定ファイルのパスに \\?\ が付かない)
  • user_path::tests::displayed_paths_have_no_verbatim_prefix (正規化したパスの表示に \\?\ が付かず、表示したパスを正規化すると元のパスに戻る)
  • user_path::tests::test_strip_verbatim_prefix_on_windows (cargo_rollback から移したテスト)
  • cargo fmt --all -- --check: pass
  • cargo clippy --locked --all-targets -- -D warnings: pass
  • cargo test --locked (Windows): pass

Closes #126

🤖 Generated with Claude Code

Windows で、depup が利用者に見せるメッセージのファイルのパスに、拡張長
パスの接頭辞 \\?\ が付いていた。ルートに minimumReleaseAge を持つ pnpm
workspace で depup --age 2w --dry-run を実行すると
"(10 days from \\?\C:\work\app\pnpm-workspace.yaml)" のように表示され、
install の復元の報告 (recovery failed for \\?\C:\...\Cargo.lock: ...) も
同じ形になっていた。

std::fs::canonicalize は Windows で \\?\ 付きのパス (verbatim path) を返す。
age の設定の出どころ (orchestrator/age.rs) や install の復元の報告
(install/transaction.rs の RollbackReport::print) は、正規化したパスを
そのまま display() で表示していた。cargo_rollback/scratch.rs には同じ
接頭辞を外す strip_verbatim_prefix があったが、表示の側では使っていなかった。

- user_path モジュールを足し、strip_verbatim_prefix を cargo_rollback から
  移して共有する。利用者に見せるパスは for_display で \\?\ を外して表示する
  (\\?\C:\... は C:\...、\\?\UNC\server\share\... は \\server\share\...)。
  ファイルの操作と比較には元のパスを使う (長いパスは \\?\ がないと開けない
  ことがある)。
- age の設定の通知と、install の復元の報告 (Scope・restored・removed・
  recovery failed・kept・写しの場所) で for_display を使う。
- AGENTS.md に書いた。

テスト: 正規化したパスの表示に \\?\ が付かず、表示したパスを正規化すると
元のパスに戻ること。age の通知の設定ファイルのパスに \\?\ が付かないこと。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@owayo owayo self-assigned this Nov 6, 2026
@coderabbitai

coderabbitai Bot commented Nov 6, 2026

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9d49ecfe-2bc9-4825-ad0a-a52d4d48f916
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@owayo
owayo merged commit af050e9 into main Nov 6, 2026
8 checks passed
@owayo
owayo deleted the fix/issue-126-display-paths-without-verbatim branch November 6, 2026 13:09
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.

Windows で、通知や報告に出るファイルのパスに \\?\ が付く

1 participant