astral-sh / ruff-vscode

A Visual Studio Code extension with support for the Ruff linter.
Other
1.06k stars 53 forks source link

Fail to recognize the Ruff config file path in the VSCode settings.json #413

Closed ArcticOc closed 7 months ago

ArcticOc commented 7 months ago

Environment

Ruff: v2024.12.0 VSCode: 1.86.2 (Universal) OS: Mac Os 14.3

Description

"ruff.lint.args": [
      "--config=$HOME/.config/pyproject.toml"
    ],

Here is the error message.

Ruff: Lint failed (error: invalid value '$HOME/.config/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 `$HOME/.config/pyproject.toml` does not exist For more information, try '--help'. ) 

This path value used to be fine, but it seems to be invalid after the most recent update to Ruff or VSCode.

Thanks!

MichaReiser commented 7 months ago

Hmm. It could be because we fail to expand $HOME.

erjac77 commented 7 months ago

We have the same problem using environment variables like ${env:PYTHON_VERSION} in path.

"ruff.path": [
  "${workspaceFolder}/dist/export/python/virtualenvs/ruff/${env:PYTHON_VERSION}/bin/ruff"
]

The error message:

Interpreter executable (/workspace/dist/export/python/virtualenvs/ruff/${env:PYTHON_VERSION}/bin/ruff) not found

Seems like predefined variables are expanded, but not the environment variables.

alkatar21 commented 7 months ago

I have a similar problem:

    "ruff.format.args": [
        "--config",
        "~/AppData/Roaming/Code/User/pyproject.toml",
    ],

This worked fine until 2024.10.0 and throws the following error since 2024.12.0:

[info] error: invalid value '~/AppData/Roaming/Code/User/pyproject.toml' for '--config <CONFIG_OPTION>'
charliermarsh commented 7 months ago

Yeah, we're failing to expand things there. I will fix now.

charliermarsh commented 7 months ago

Fix here: https://github.com/astral-sh/ruff/pull/10219