Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

Default to `uv` package manager when launched from `uv` (#5213)

Trevor Manzb068f2a133a6
diff --git a/marimo/_config/packages.py b/marimo/_config/packages.py
index aea4ddf545..f7bb0427bc 100644
--- a/marimo/_config/packages.py
+++ b/marimo/_config/packages.py
@@ -14,6 +14,11 @@ PackageManagerKind = Literal["pip", "rye", "uv", "poetry", "pixi"]
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 6548a2b859..acb48259cf 100644
--- a/tests/_config/test_config_packages.py
+++ b/tests/_config/test_config_packages.py
@@ -78,6 +78,8 @@ TEST_CASES: list[
({"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":