Skip to content

fix: handle PermissionError in version check cache write#4959

Open
scinttt wants to merge 1 commit intoAider-AI:mainfrom
scinttt:fix/uncaught-permission-error-4958
Open

fix: handle PermissionError in version check cache write#4959
scinttt wants to merge 1 commit intoAider-AI:mainfrom
scinttt:fix/uncaught-permission-error-4958

Conversation

@scinttt
Copy link
Copy Markdown

@scinttt scinttt commented Mar 26, 2026

Problem

check_version() crashes with an uncaught PermissionError when 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 with root_squash).

Traceback from the issue:

File "versioncheck.py", line 95, in check_version
    VERSION_CHECK_FNAME.touch()
PermissionError: [Errno 13] Permission denied: '/root/.aider/caches/versioncheck'

Root Cause

The finally block in check_version() calls mkdir() and touch() without any exception handling. Since finally runs unconditionally, a PermissionError (or any OSError) propagates as an uncaught exception and crashes aider.

Fix

Wrap the finally block's filesystem operations in try/except OSError. Using OSError (parent of PermissionError) also handles other filesystem issues like read-only mounts and disk-full scenarios. A silent pass is 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.py with 4 test cases:

  • PermissionError on touch() does not crash
  • PermissionError on mkdir() does not crash
  • Generic OSError (e.g. read-only filesystem) does not crash
  • Normal version check behavior is preserved

Fixes #4958

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
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 26, 2026

CLA assistant check
All committers have signed the CLA.

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.

Uncaught PermissionError in pathlib.py line 1305

2 participants