Repository navigation
Raise the original error when a launcher can't be written - #269
Merged
Merged
Conversation
If writing an .exe launcher fails and there is no existing file, the .deleteme logic tried to rename the missing file, and the resulting FileNotFoundError replaced the original error (e.g. no write permission for the scripts directory). Re-raise the original error in that case.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #269 +/- ##
==========================================
- Coverage 81.49% 81.04% -0.45%
==========================================
Files 24 24
Lines 8885 9144 +259
Branches 1747 1564 -183
==========================================
+ Hits 7241 7411 +170
- Misses 1300 1386 +86
- Partials 344 347 +3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Summary
On Windows, if
ScriptMakercan't write an.exelauncher and there is no existing file at that path, the original error is lost: the.deletemelogic tries to rename a file that doesn't exist, and thatFileNotFoundErroris raised instead.This is what pip users get when the scripts directory isn't writable (e.g. a Python installed for all users, used without admin rights). See pypa/pip#9023:
pip only shows its permission hint when the error is
EACCES, so the real cause is hidden.Change
If writing the launcher fails and the file doesn't exist, there's nothing to move aside, so the original exception is re-raised. When the file does exist (e.g. because it's running), the
.deletemelogic works as before.Testing
tests/test_scripts.py: a failing write with no existing file raises the original error and leaves nothing behind (fails before this change withFileNotFoundError), and an existing launcher whose first write fails is still replaced.tests/test_all.pyon Windows 11 with Python 3.14: the same results as onmasterplus the two new tests (6 tests fail or error both before and after, all unrelated to scripts).Scriptsfolder denies creating files, installingcowsay:[WinError 2] ... cowsay.exe.deletemeerror above[Errno 13] Permission denied: '...\Scripts\cowsay.exe'followed by pip'sCheck the permissions.hint