vscode-ruff icon indicating copy to clipboard operation
vscode-ruff copied to clipboard

Fail to recognize the Ruff config file path for lintning in the VSCode settings.json

Open Pomurnik opened this issue 1 year ago • 1 comments

Environment

Ruff Extension: v2024.24.0 VSCode: 1.88.1 OS: Windows 10 Python: 3.8.15 Ruff: 0.4.7 Import Strategy: fromEnvironment

Description

"ruff.lint.args": [
      "--config=${workspaceFolder}/pyproject.toml"
  ],
"ruff.format.args": [
    "--config=${workspaceFolder}/pyproject.toml"
]

Here is the error message.

Ruff: Lint failed (error: invalid value '${workspaceFolder}/pyproject.toml' for '--config <CONFIG_OPTION>' tip: A `--config` flag must either be a path to a `.toml` configuration file or a TOML `<KEY> = <VALUE>` pair overriding a specific configuration option It looks like you were trying to pass a path to a configuration file. The path `{workspaceFolder}/pyproject.toml` does not exist For more information, try '--help'. ) 

Formatting works well and recognizes the path to pyproject.toml, unfortunately the error appears with the same path for lint.

Thanks!

Pomurnik avatar Jun 04 '24 14:06 Pomurnik

Can you try this with the latest version? It's working fine for me i.e., it's expanding the ${workspaceFolder} variable:

2024-07-23 09:50:19.778 [info] Running Ruff with: /Users/dhruv/.local/bin/ruff ['check', '--force-exclude', '--no-cache', '--no-fix', '--quiet', '--output-format', 'json', '-', '--config=/Users/dhruv/playground/ruff/pyproject.toml', '--stdin-filename', '/Users/dhruv/playground/ruff/src/lsp.py']

You can refer to logs with either Ruff: Show Logs command or Developer: Show Logs (select "Ruff").

dhruvmanila avatar Jul 23 '24 04:07 dhruvmanila

Closing this as resolved. Both these settings are now deprecated and the recommendation is to switch to using ruff.configuration instead which also supports expanding variables like ${workspaceFolder}. Feel free to ask any other questions that you might have.

dhruvmanila avatar Feb 12 '25 11:02 dhruvmanila