Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ArcticOc opened this issue Feb 21, 2024 · 5 comments · Fixed by astral-sh/ruff#10219
Closed
Assignees
Labels
bug Something isn't working

Comments

@ArcticOc
Copy link

ArcticOc commented Feb 21, 2024

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
Copy link
Member

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

@MichaReiser MichaReiser added the bug Something isn't working label Feb 21, 2024
@erjac77
Copy link

erjac77 commented Feb 21, 2024

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
Copy link

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
Copy link
Member

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

@charliermarsh
Copy link
Member

Fix here: astral-sh/ruff#10219

@charliermarsh charliermarsh self-assigned this Mar 4, 2024
charliermarsh added a commit to astral-sh/ruff that referenced this issue Mar 4, 2024
## Summary

When users provide configurations via `--config`, we use `shellexpand`
to ensure that we expand signifiers like `~` and environment variables.

In #9599, we modified `--config`
to accept either a path or an arbitrary setting. However, the detection
(to determine whether the value is a path or a setting) was lacking the
`shellexpand` behavior -- it was downstream. So we were always treating
paths like `~/ruff.toml` as values, not paths.

Closes astral-sh/ruff-vscode#413.
nkxxll pushed a commit to nkxxll/ruff that referenced this issue Mar 10, 2024
## Summary

When users provide configurations via `--config`, we use `shellexpand`
to ensure that we expand signifiers like `~` and environment variables.

In astral-sh#9599, we modified `--config`
to accept either a path or an arbitrary setting. However, the detection
(to determine whether the value is a path or a setting) was lacking the
`shellexpand` behavior -- it was downstream. So we were always treating
paths like `~/ruff.toml` as values, not paths.

Closes astral-sh/ruff-vscode#413.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants