Skip to content

Commit 8a6fac9

Browse files
chris-reevesjhossbach
authored andcommitted
Fall back to python module if ruff executable is missing
Fixes #69.
1 parent a4fac02 commit 8a6fac9

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

pylsp_ruff/plugin.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,7 @@ def run_ruff(
510510

511511
arguments = subcommand.build_args(document_path, settings, fix, extra_arguments)
512512

513+
p = None
513514
if executable is not None:
514515
log.debug(f"Calling {executable} with args: {arguments} on '{document_path}'")
515516
try:
@@ -518,7 +519,11 @@ def run_ruff(
518519
p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE)
519520
except Exception:
520521
log.error(f"Can't execute ruff with given executable '{executable}'.")
521-
else:
522+
if p is None:
523+
log.debug(
524+
f"Calling ruff via '{sys.executable} -m ruff'"
525+
f" with args: {arguments} on '{document_path}'"
526+
)
522527
cmd = [sys.executable, "-m", "ruff", str(subcommand)]
523528
cmd.extend(arguments)
524529
p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE)

0 commit comments

Comments
 (0)