astral-sh/uv

Bug: ModuleNotFoundError related to venv uv_cache.json when store in iCloud

Open

#9,902 opened on Dec 15, 2024

View on GitHub
 (7 comments) (0 reactions) (0 assignees)Rust (84,934 stars) (3,111 forks)batch import
help wantedneeds-mre

Description

Description

uv run fails with a ModuleNotFoundError when the venv uv_cache.json is present. This doesn’t happen on an earlier macOS version.

Environment

  • uv version: uv 0.5.9 (0652800cb 2024-12-13)
  • OS: macOS 15.1.1 (bug present)
  • Also tested on: macOS 14.3.1 (bug not present)

Minimal Reproduction Steps

uv init --package foo
cd foo
uv run foo

Bug Description

uv run foo correctly prints Hello from foo! for a few seconds. Then running it results in:

ModuleNotFoundError: No module named 'foo'

Additional Information

  1. Deleting the cache file resolves the issue temporarily:
rm .venv/lib/python3.13/site-packages/foo-0.1.0.dist-info/uv_cache.json
  1. Setting the environment variable UV_NO_INSTALLER_METADATA=1 uv run foo prevents the issue.

Debug Information

DEBUG uv 0.5.9 (0652800cb 2024-12-13)
DEBUG Found project root: `/Users/user/Documents/code/py/foo`
DEBUG No workspace root found, using project root
DEBUG Discovered project `foo` at: /Users/user/Documents/code/py/foo
DEBUG Reading Python requests from version file at `/Users/user/Documents/code/py/foo/.python-version`
DEBUG Using Python request `3.13` from version file at `.python-version`
TRACE Cached interpreter info for Python 3.13.1, skipping probing: .venv/bin/python3
DEBUG The virtual environment's Python version satisfies `3.13`
DEBUG Using request timeout of 30s
DEBUG Found static `pyproject.toml` for: foo @ file:///Users/user/Documents/code/py/foo
DEBUG No workspace root found, using project root
DEBUG Existing `uv.lock` satisfies workspace requirements
DEBUG Using request timeout of 30s
TRACE Comparing installed with source: Url(InstalledDirectUrlDist { name: PackageName("foo"), version: "0.1.0", direct_url: LocalDirectory { url: "file:///Users/user/Documents/code/py/foo", dir_info: DirInfo { editable: Some(true) } }, url: Url { scheme: "file", cannot_be_a_base: false, username: "", password: None, host: None, port: None, path: "/Users/user/Documents/code/py/foo", query: None, fragment: None }, editable: true, path: "/Users/user/Documents/code/py/foo/.venv/lib/python3.13/site-packages/foo-0.1.0.dist-info", cache_info: Some(CacheInfo { timestamp: Some(Timestamp(SystemTime { tv_sec: 1734188435, tv_nsec: 526620830 })), commit: None, tags: None }) }) Directory { install_path: "/Users/user/Documents/code/py/foo", editable: true, virtual: false, url: VerbatimUrl { url: Url { scheme: "file", cannot_be_a_base: false, username: "", password: None, host: None, port: None, path: "/Users/user/Documents/code/py/foo", query: None, fragment: None }, given: None } }
DEBUG Requirement already installed: foo==0.1.0 (from file:///Users/user/Documents/code/py/foo)
DEBUG Using Python 3.13.1 interpreter at: /Users/user/Documents/code/py/foo/.venv/bin/python3
DEBUG Running `foo`
Traceback (most recent call last):
  File "/Users/user/Documents/code/py/foo/.venv/bin/foo", line 5, in <module>
    from foo import main
ModuleNotFoundError: No module named 'foo'
DEBUG Command exited with code: 1
DEBUG uv 0.5.9 (0652800cb 2024-12-13)
DEBUG Found project root: `/Users/user/Documents/code/py/foo`
DEBUG No workspace root found, using project root
DEBUG Discovered project `foo` at: /Users/user/Documents/code/py/foo
DEBUG Reading Python requests from version file at `/Users/user/Documents/code/py/foo/.python-version`
DEBUG Using Python request `3.13` from version file at `.python-version`
TRACE Cached interpreter info for Python 3.13.1, skipping probing: .venv/bin/python3
DEBUG The virtual environment's Python version satisfies `3.13`
DEBUG Using request timeout of 30s
DEBUG Found static `pyproject.toml` for: foo @ file:///Users/user/Documents/code/py/foo
DEBUG No workspace root found, using project root
DEBUG Existing `uv.lock` satisfies workspace requirements
DEBUG Using request timeout of 30s
TRACE Comparing installed with source: Url(InstalledDirectUrlDist { name: PackageName("foo"), version: "0.1.0", direct_url: LocalDirectory { url: "file:///Users/user/Documents/code/py/foo", dir_info: DirInfo { editable: Some(true) } }, url: Url { scheme: "file", cannot_be_a_base: false, username: "", password: None, host: None, port: None, path: "/Users/user/Documents/code/py/foo", query: None, fragment: None }, editable: true, path: "/Users/user/Documents/code/py/foo/.venv/lib/python3.13/site-packages/foo-0.1.0.dist-info", cache_info: None }) Directory { install_path: "/Users/user/Documents/code/py/foo", editable: true, virtual: false, url: VerbatimUrl { url: Url { scheme: "file", cannot_be_a_base: false, username: "", password: None, host: None, port: None, path: "/Users/user/Documents/code/py/foo", query: None, fragment: None }, given: None } }
DEBUG Requirement installed, but not fresh: foo==0.1.0 (from file:///Users/user/Documents/code/py/foo)
DEBUG Directory source requirement already cached: foo==0.1.0 (from file:///Users/user/Documents/code/py/foo)
[File removal logs...]
DEBUG Uninstalled foo (9 files, 1 directory)
Uninstalled 1 package in 1ms
[Installation logs...]
Installed 1 package in 3ms
DEBUG Using Python 3.13.1 interpreter at: /Users/user/Documents/code/py/foo/.venv/bin/python3
DEBUG Running `foo`
Hello from foo!
DEBUG Command exited with code: 0

Contributor guide