crash when type checking file in a read only directory
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
Crash Report
mypy gives INTERNAL_ERROR when type checking files on read only filesystem (e.g. ro bind mount).
This can happen when running inside docker/checking files that you don't have write permission to.
Traceback
$ mypy hello.py --show-traceback
error: INTERNAL ERROR -- Please try using mypy master on GitHub:
https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build
Please report a bug at https://github.com/python/mypy/issues
version: 2.1.0
Traceback (most recent call last):
File "/home/karlicos/.local/share/uv/tools/mypy/lib/python3.14/site-packages/mypy/__main__.py", line 16, in console_entry
main()
~~~~^^
File "mypy/main.py", line 154, in main
File "mypy/main.py", line 244, in run_build
res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
File "mypy/build.py", line 385, in build
File "mypy/build.py", line 1916, in create_metastore
mds: MetadataStore = SqliteMetadataStore(
File "mypy/metastore.py", line 192, in __init__
File "<frozen os>", line 226, in makedirs
File "<frozen os>", line 236, in makedirs
OSError: [Errno 30] Read-only file system: '.mypy_cache'
To Reproduce
mkdir /tmp/ro
cd /tmp/ro
echo 'x: int = "a"' > hello.py
chmod -w /tmp/ro
mypy hello.py --show-traceback
Your Environment
- Mypy version used: 2.1.0
- Mypy command-line flags: N/A
- Mypy configuration options from
mypy.ini(and other config files): N/A - Python version used: 3.14
- Operating system and version:
Linux 7.0.0-15-generic #15-Ubuntu SMP PREEMPT_DYNAMIC
Debugging attempt
I also reproduced in a clean environment with Claude, so pretty sure it's unaffected by my system conviguration.
- with
--no-sqlite-cachethe crash doesn't happen - bisection shows that it started happening when sqlite cache became the default, on 1.20
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the read-only /tmp/ro setup, then read mypy/build.py around create_metastore and mypy/metastore.py around SqliteMetadataStore. Compare behavior with --no-sqlite-cache and verify that type checking a read-only directory reports the source error without an INTERNAL_ERROR or attempted cache creation failure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, sqlite
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100