fix: handle PermissionError in version check cache write#4959
Open
scinttt wants to merge 1 commit intoAider-AI:mainfrom
Open
fix: handle PermissionError in version check cache write#4959scinttt wants to merge 1 commit intoAider-AI:mainfrom
scinttt wants to merge 1 commit intoAider-AI:mainfrom
Conversation
Wrap the finally block in check_version() with try/except OSError so that permission errors on the cache file do not crash aider. Fixes Aider-AI#4958
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.
Problem
check_version()crashes with an uncaughtPermissionErrorwhen the version cache file (~/.aider/caches/versioncheck) cannot be written. This prevents aider from starting entirely in restricted environments (read-only filesystems, Docker containers with--read-only, SELinux/AppArmor policies, NFS withroot_squash).Traceback from the issue:
Root Cause
The
finallyblock incheck_version()callsmkdir()andtouch()without any exception handling. Sincefinallyruns unconditionally, aPermissionError(or anyOSError) propagates as an uncaught exception and crashes aider.Fix
Wrap the
finallyblock's filesystem operations intry/except OSError. UsingOSError(parent ofPermissionError) also handles other filesystem issues like read-only mounts and disk-full scenarios. A silentpassis appropriate here since the version cache is non-critical — the only consequence of failure is that the next launch will re-check PyPI, which is harmless.Tests
Added
tests/basic/test_versioncheck.pywith 4 test cases:PermissionErrorontouch()does not crashPermissionErroronmkdir()does not crashOSError(e.g. read-only filesystem) does not crashFixes #4958