The ruff VSCode extension doesn't appear to function in a particular VSCode dev-extension environment (works in "default" environment)
wolfch-elsevier opened this issue · comments
Here's a simple piece of contrived code:
from requests import ReadTimeout, Request, Response, Timeout, TooManyRedirects
from sys import argv
import logging
import os
def main() -> None:
pass
In the first case, I wanted the extension to perform the equivalent of isort
, so in VSCode, I invoke Shift-Command-P
(MacOs) and from the list:
Ruff: Format Imports
...nothing happens - the code doesn't change.
Then, from the command line, I invoke:
ruff check --fix --select I roughruff.py
...where roughtruff.py
is the quoted code above and this time, it gets changed to:
import logging
import os
from sys import argv
from requests import ReadTimeout, Request, Response, Timeout, TooManyRedirects
def main() -> None:
pass
So ruff
can successfully replace isort
but only via the command line - the VSCode extension doesn't work.
Wow - thanks for the timely reply! I look at the bottom strip and only see:
I don't see "Ruff"; I do see a warning, "Select Interpreter" but when invoke Shift-Command-P
, it shows the "Selected Interpeter" to be:
...which is correct. I should mention this is running inside of a dev-container (sorry, I should have made that clear initially)
I re-tried "Select Interpreter" which select the default
(not correct in terms of installed dependencies) but this tine the Ruff VSCode extension works - see the attached log.
ruff.log
but I expected it to work with the selected hatch environment. Let me change the title of this issue - and offer my apologies.. this dev-container concept is a bit difficult.
Oh God - it totally works in the dev-container - sorry!. However: I have some caveats for people looking to use this extension in a VSCode dev-container. If you have a monorepo with each service having a corresponding hatch environment other than default
, you need to insure that the ruff dependency is declared and installed in the particular hatch environment you are using.
The use-case was specific to using within a dev-container which lead to the false belief it was not working.
Glad to see it resolved, sorry you ran into trouble!