ruff
ruff copied to clipboard
[Windows] Issues when running as a module
If the interpreter path contains spaces (e.g. C:\Program Files\Python311\python.exe
), then ruff produces the following output: Files\Python311\Scripts\ruff:0:0: E902 The system cannot find the path specified
and exits with code 1.
Replacing
sys.exit(os.spawnv(os.P_WAIT, ruff, [ruff, *sys.argv[1:]]))
with
sys.exit(subprocess.call([ruff, *sys.argv[1:]]))
in __main__.py
seems to resolve the issue.
@andriilahuta Could you confirm this is still an issue? We've added windows testing in the meantime, so if it's still an issue we should extend our testing suite (and fix it).
@sbrugman Still an issue.
To reproduce, you can run ruff like this: "C:\Program Files\Python311\python.exe" -m ruff .
.
Replacing os.spawnv
with subprocess.call
fixes the issue for me.
Suppose we could add this to the maturin test stage in the CI pipeline. Needs some testing to ensure there are no regressions.
Coming in to confirm this is happening for me too. Synced the vscode setting from my macbook (where ruff runs fine), to my windows PC and when ruff is set to handle source.fixAll
, its actually wiping the python file on save.
Replacing the file with
[
{
"code": "E902",
"message": "The system cannot find the file specified. (os error 2)",
"fix": null,
"location": {"row": 1, "column": 1},
"end_location": {"row": 1, "column": 1},
"filename": "c:\\Users\\rhino\\Downloads\\folder with spaces in it\\-",
},
{
"code": "E902",
"message": "The system cannot find the file specified. (os error 2)",
"fix": null,
"location": {"row": 1, "column": 1},
"end_location": {"row": 1, "column": 1},
"filename": "c:\\Users\\rhino\\Downloads\\folder with spaces in it\\line-length = 100",
},
]
Thankfully, black comes in after and auto corrects the JSON to a Python friendly dict or I'd have been REALLY sad :,)
Woah, the Python file contents are replaced by that JSON?
yeah, super weird interaction!
Running python 3.11 but it might be an issue too with the fact that my Windows PC's installation is syncing settings from my Macbook's with no regard for what that might mean. I can dig into what settings are needed for repro if y'all can't get a repro of the issue down
We've now implemented this change in #5115, this should also fix your problem. If it doesn't, please feel free to reopen.