Fix Windows --install-pip crash and enable long path support#8255
Open
youknowone wants to merge 1 commit into
Open
Fix Windows --install-pip crash and enable long path support#8255youknowone wants to merge 1 commit into
--install-pip crash and enable long path support#8255youknowone wants to merge 1 commit into
Conversation
Contributor
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (4)
📝 WalkthroughWalkthroughWindows CRT errno values are preserved in I/O errors, filesystem failure paths return corrected errors, and executable prefix calculation now uses the detected executable directory with an absolute Windows fallback. ChangesWindows compatibility updates
Estimated code review effort: 3 (Moderate) | ~20 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
getpath: on Windows, default_prefix falls back to the executable directory instead of a bare "C:" when landmark search fails. host_env: errno_io_error carries the raw CRT errno as an io::Error payload (CrtErrno) instead of translating it to a Win32 error code and back. The round-trip collapsed every errno outside the errno_to_winerror table to EINVAL and attached a spurious winerror to the OSError. posix_errno recovers the exact errno from the payload; ftruncate reuses the same path. fstat now reports ERROR_INVALID_HANDLE for an invalid fd.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #8246.
On Windows,
rustpython --install-pipcrashed withOSError: [Errno 22] Invalid argument: 'C:\accesstest_deleteme_fishfingers_custard_...'. Two independent defects combined to cause it, plus a related long-path gap; each is fixed below.1.
sys.prefixfell back to a bare drive rootWhen landmark search fails to locate the stdlib,
default_prefix()returned"C:"on Windows. pip then derivedsite-packagesunder that bare drive and, viatest_writable_dir, walked up to the drive root and tried to create a probe file there — which standard users cannot write.Fix: fall back to the executable's own directory, which on Windows is the natural prefix (the stdlib lives directly under
<prefix>\Lib).2. C runtime errno was distorted to EINVAL
os.open(and other CRT calls) round-tripped the C runtimeerrnothrough a Win32 error code and back. Any errno missing from the smallerrno_to_winerrortable collapsed toERROR_INVALID_FUNCTION→ EINVAL, and a spuriouswinerrorwas attached to theOSError. pip only catchesFileExistsError/PermissionError, so a distorted error crashed it.Fix: carry the raw CRT errno as the
io::Errorpayload soposix_errnoreports it exactly and nowinerroris attached — matchingos.openon Windows.fstatnow reportsERROR_INVALID_HANDLEexplicitly for an invalid fd.3. No
longPathAwaremanifestThe Windows binary had no application manifest, so paths longer than
MAX_PATHwere rejected for length (ENOENT), and a path component over 255 chars did not report EINVAL. The executable now embeds a manifest declaringlongPathAware, matchingpython.exe.Verification (Windows 11)
sys.prefixfalls back to the executable directory; pip'stest_writable_dirprobes a writable location instead of the drive root.open,read,dup,lseek,fstatmatch CPython.cargo test(host_env, vm) andtest_os,test_io,test_fileio,test_site,test_sysconfig,test_ntpath,test_pathlib,test_tempfilepass.Summary by CodeRabbit