astral-sh/ruff-vscode

Using config file in devcontainers

ido-greenfeld opened this issue · 3 comments

Hi,

I'm using this great extension with devcontainers.

Currently, I've set ruff to read it's configuration like this - "ruff.lint.args": ["--config=.devcontainer/ruff.toml"]
This means that I have to copy the ruff.toml file into each one of my projects, since once I'm inside the devcontainer, I cannot access path on the host machine

I want to be able to define my settings in a single ruff.toml file which all devcontainer use
Is this possible?

Alternatively, can I define my configuration directly by using ruff.lint.args instead of using a file?

I'm sorry but I not familiar with devcontainers (I haven't used them before).

You're saying that you can't access a file on the host machine. Does that mean that ruff runs inside the devcontainer? Could you put the configuration in a project folder alongside your code (e.g. into the .vscode directory together with the recommended plugins)?

For reference. There's a best practice guide that goes into detail [what extensions must do to run in devcontainers](It might be worth reading through to see if there's anything we need to do to support dev containers https://code.visualstudio.com/api/advanced-topics/remote-extensions)

The guide explains that there are ways for the extension to store data (that is persisted across devcontainers) but there's no explanation on how to handle configuration files. It might be worth for us to take a look how other extensions handle setting files (e.g. deno?)

I'm sorry but I not familiar with devcontainers (I haven't used them before).

You're saying that you can't access a file on the host machine. Does that mean that ruff runs inside the devcontainer? Could you put the configuration in a project folder alongside your code (e.g. into the .vscode directory together with the recommended plugins)?

Yes, exactly
Ruff runs inside the dev container. as a matter of fact, the entire vscode server runs inside the container and the vscode app connects to it

I can put the configuration file in the project folder. but that would mean I'll have to duplicate it for each project. and if at some point I want to make a change I would have to edit multiple copies of the file.

In any case, what I ended up doing for now is mounting a single file from the host machine to the dev container, I did have to edit all of my devcontainer.json files, but at least now when I change that single file on the host my configuration would affect all of the devcontainers