Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prioritize use of ruff commands installed in the environment #52

Merged
merged 1 commit into from
Feb 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion ruff_lsp/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import pathlib
import platform
import re
import shutil
import sys
import sysconfig
from typing import Any, Sequence, cast
Expand Down Expand Up @@ -727,7 +728,11 @@ def _executable_path(settings: dict[str, Any]) -> str:
# If the interpreter is same as the interpreter running this process, get the
# script path directly.
path = os.path.join(sysconfig.get_path("scripts"), TOOL_MODULE)
if bundle and not os.path.exists(path):
environment_path = shutil.which("ruff")
if environment_path:
log_to_output(f"Using environment executable: {environment_path}")
path = environment_path
elif bundle and not os.path.exists(path):
log_to_output(
f"Interpreter executable ({path}) not found; "
f"falling back to bundled executable: {bundle}"
Expand Down