Skip to content

crash when type checking file in a read only directory #21495

@karlicoss

Description

@karlicoss

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-cache the crash doesn't happen
  • bisection shows that it started happening when sqlite cache became the default, on 1.20

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions