-
Notifications
You must be signed in to change notification settings - Fork 56
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
Use existing ruff in active python environment #141
Comments
If you use |
Uff, totally missed that setting, and there are only nine hahaha. Thanks! |
@charliermarsh Instead of requiring a setting to be changed, is it possible to have the Ruff extension prefer the workspace environment by default if it can find that
We have a shared repo for our workplace, and we want to ensure that everyone using it with VSCode has a consistent dev experience out of the box. So we'd like Thanks for considering! |
Yeah I think it makes sense to change the default. |
Closes astral-sh#141 The docs claimed that `useBundled` was the default import strategy, but it seems that's in fact not the case, based on https://github.com/charliermarsh/ruff-vscode/blob/f57ae4f1cad2e7ea3a9caa307898fdfacbd180f1/src/common/settings.ts#L51 Per discussion here astral-sh#141 (comment), it was agreed to that `fromEnvironment` was the right default, so this updates docs to reflect that existing default.
Okay, nice, it looks like the import strategy default was actually already being set as It's just that the docs didn't reflect that. I made a PR to update them: #144 |
Hm, I'm still having problems. Even if I use the As you can see in the image, Ruff says "Using environment executable: /Users/thomas/mambaforge/bin/ruff", which is the base environment, while VS Code's active environment is not the base environment, but one named "grapy" (see lower right corner of the screenshot). I'm pretty sure at some point I saw Ruff pointing at the correct executable in the active environment. Not sure what changed. |
FWIW, if I uninstall Ruff from the base environment it then finds the correct binary in the active environment. Is it possible that the resolution logic is "backwards"? |
Lemme check real quick... |
Yeah I think it's wrong. It should be using current environment, then global environment, but it's inverted AFAICT. |
Ok. No problem, I've got a workaround for now. Just thought it better to report. Thanks for looking into it! |
Hi, unless I'm missing something, it's not currently possible to configure the Ruff extension to use an already existing Ruff install in the currently active Python environment. There are options to manually set a fixed path to the interpreter and Ruff binary, but that's no use if you habitually switch between different python environments in VS Code.
The problem is that this leads to possibly incongruent linting via the extension and any configured pre-commit linting with Ruff. If the extension updates and introduces new rules, e.g., but the pre-commit Ruff has a fixed prior version, the result of the two may differ.
Not sure if it's possible to add the option to use the same Ruff already installed in the environment, or used by pre-commit, or if there is an alternative way to ensure consistency?
The text was updated successfully, but these errors were encountered: