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.

Find ruff when it's not on PATH (#2980)

Alexander Kislukhin3f4858542716
diff --git a/marimo/_utils/formatter.py b/marimo/_utils/formatter.py
index 11804b15ad..c4cd207484 100644
--- a/marimo/_utils/formatter.py
+++ b/marimo/_utils/formatter.py
@@ -2,6 +2,7 @@
from __future__ import annotations
import subprocess
+import sys
from typing import Dict
from marimo import _loggers
@@ -42,9 +43,9 @@ class DefaultFormatter(Formatter):
class RuffFormatter(Formatter):
def format(self, codes: CellCodes) -> CellCodes:
- try:
- process = subprocess.run("ruff", capture_output=True)
- except FileNotFoundError:
+ ruff_cmd = [sys.executable, "-m", "ruff"]
+ process = subprocess.run([*ruff_cmd, "--help"], capture_output=True)
+ if process.returncode != 0:
LOGGER.warning(
"To enable code formatting, install ruff (pip install ruff)"
)
@@ -55,7 +56,7 @@ class RuffFormatter(Formatter):
try:
process = subprocess.run(
[
- "ruff",
+ *ruff_cmd,
"format",
"--line-length",
str(self.line_length),