astral-sh/ruff-vscode

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

ArcticOc opened this issue · 5 comments

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!

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

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.

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>'

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