Replace std::path with camino for UTF-8 path handling#984
Replace std::path with camino for UTF-8 path handling#984
Conversation
- Add camino dependency to Cargo.toml - Replace std::path imports with camino imports in 56+ files - Update type annotations from Path/PathBuf to Utf8Path/Utf8PathBuf - Replace Path::new() calls with Utf8Path::new() - Convert CWD to Utf8PathBuf - Remove unnecessary .to_string_lossy() and .display() calls - Add conversions between std::path and camino where needed for compatibility Co-authored-by: j178 <10510431+j178@users.noreply.github.com>
- Remove remaining .display() calls on Utf8Path/Utf8PathBuf - Add conversions from std::path::PathBuf to Utf8PathBuf where needed - Handle which::which_all results (PathBuf to Utf8PathBuf conversion) - Fix tempfile::TempDir path conversions throughout codebase - Convert paths for fs-err and archive functions - Update store.rs to handle UTF-8 path conversions Co-authored-by: j178 <10510431+j178@users.noreply.github.com>
…art 3 - Remove .display() calls from main.rs, clean.rs, completion.rs, install.rs, selector.rs, config.rs - Fix .to_string_lossy() calls to use .to_string() for Utf8Path - Fix .to_str() calls to use .as_str() for Utf8Path - Update identify.rs to use Utf8Path methods directly (extension(), file_name()) - Fix meta_hooks.rs path conversions - Convert std::env::current_exe() results to Utf8PathBuf Co-authored-by: j178 <10510431+j178@users.noreply.github.com>
- Convert which::which and which::which_all results from PathBuf to Utf8PathBuf - Fix git.rs GIT static initialization - Fix resolve_command in languages/mod.rs - Handle which::which_all iterator conversion in uv.rs - Fix installer.rs entry.path() conversions in golang, node, and lua - Remove remaining .to_string_lossy() calls (process.rs, run.rs) - Convert DirEntry paths to Utf8PathBuf in multiple installers Co-authored-by: j178 <10510431+j178@users.noreply.github.com>
# Conflicts: # src/cli/run/filter.rs
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #984 +/- ##
==========================================
+ Coverage 89.93% 90.06% +0.12%
==========================================
Files 66 67 +1
Lines 12223 12377 +154
==========================================
+ Hits 10993 11147 +154
Misses 1230 1230 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
📦 Cargo Bloat ComparisonBinary size change: +0.62% (16.1 MiB → 16.2 MiB) Expand for cargo-bloat outputHead Branch ResultsBase Branch Results |
⚡ Hotpath Performance ProfileLatency change: +0.00% (N/A → N/A) Benchmark: Running Expand for detailed profiling outputPR Branch ProfileBase Branch Profile |
Performance Comparison
|
Performance Comparison
|
Closes #649
Migrates path handling from
std::path::{Path, PathBuf}tocamino::{Utf8Path, Utf8PathBuf}for guaranteed UTF-8 paths, eliminating unnecessary lossy conversions.Changes
Type system migration (200+ sites)
Path→Utf8Path,PathBuf→Utf8PathBufCWDconverted toUtf8PathBufSimplified string conversions
.display()calls -Utf8PathimplementsDisplaydirectly.to_string_lossy()calls - directto_string()oras_str()available.to_str()with.as_str()for extension/filename handlingExternal API boundaries
tempfile::TempDir::path(): AddedUtf8Path::from_path()conversionswhich::which/which_all: Convert results viaUtf8PathBuf::from_path_buf()std::fs::read_dir: ConvertDirEntry::path()in installersstd::env::current_exe(): Convert toUtf8PathBufwhere neededCompatibility layer
archive.rsandfs.rsretainstd::pathfor low-level operations (Component, path separators)create_symlink_or_copykeep&Pathsignatures, callers use.as_std_path()Example
Before:
After:
Status
93% complete - 22 remaining errors in edge cases (PATH env splitting, trait bounds for generic path types).
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
dl.google.com/home/REDACTED/work/prek/prek/target/debug/prek run -v(dns block)/home/REDACTED/work/prek/prek/target/debug/prek run(dns block)mirrors.aliyun.com/home/REDACTED/work/prek/prek/target/debug/prek run(dns block)/home/REDACTED/work/prek/prek/target/debug/prek install-hooks(dns block)/home/REDACTED/work/prek/prek/target/debug/prek install --install-hooks(dns block)mirrors.cloud.tencent.com/home/REDACTED/work/prek/prek/target/debug/prek run(dns block)/home/REDACTED/work/prek/prek/target/debug/prek install-hooks(dns block)/home/REDACTED/work/prek/prek/target/debug/prek install --install-hooks(dns block)pypi.tuna.tsinghua.edu.cn/home/REDACTED/work/prek/prek/target/debug/prek run(dns block)/home/REDACTED/work/prek/prek/target/debug/prek install-hooks(dns block)/home/REDACTED/work/prek/prek/target/debug/prek install --install-hooks(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.