diff --git a/marimo/_config/packages.py b/marimo/_config/packages.py index aea4ddf5454..f7bb0427bc2 100644 --- a/marimo/_config/packages.py +++ b/marimo/_config/packages.py @@ -14,6 +14,11 @@ def infer_package_manager() -> PackageManagerKind: """Infer the package manager from the current project.""" + # `uv run` sets `UV` to the uv executable path + # https://github.com/astral-sh/uv/issues/8775 + if os.environ.get("UV") is not None: + return "uv" + try: # Get the project root by looking for common project files current_dir = Path.cwd() diff --git a/tests/_config/test_config_packages.py b/tests/_config/test_config_packages.py index 6548a2b8598..acb48259cff 100644 --- a/tests/_config/test_config_packages.py +++ b/tests/_config/test_config_packages.py @@ -78,6 +78,8 @@ def test_infer_package_manager_from_lockfile(mock_cwd: Path): ({"pixi.toml": ""}, {}, {}, "pixi"), # Test fallback to pip ({}, {}, {}, "pip"), + # Test fallback to uv when running inside `uv run` / `uvx` + ({}, {"UV": "/usr/bin/uv"}, {}, "uv"), ] if sys.platform != "win32":