koxudaxi/ruff-pycharm-plugin

Use a relative path for ruff executable in the configuration file

clement-escolano opened this issue ยท 6 comments

Is your feature request related to a problem? Please describe.
In the project I am currently working on, we all use PyCharm and share some of the IDE configurations (stored in the .idea folder). We would like to share the configuration of the Ruff plugin but this is not possible currently as not all developers installed Python in the same way and the path of ruff executable is not the same for everyone and this path is written in the ruff.xml configuration file.

Describe the solution you'd like
A way to share the ruff.xml file with people that don't have the same path to ruff. Some ideas (I don't know if there are feasible):

  • store the path with a variable to the current Python path (the path would look like $PYTHONHOME/bin/ruff)
  • only store the path in the file if it is in a non-default place
  • have an option to store the path in the Ruff plugin

Describe alternatives you've considered
Not having the path in the file works (the plugin auto-detects it probably) but from time to time (mostly when opening the Ruff plugin in the settings modal), the ruff.xml file is modified to add the path which makes it cumbersome to the other people.

Additional context
None

@clement-escolano
I'm sorry for my late reply.
Thank you for your creating the issue.
OK, I will check your suggestion to see whether I can implement it.

This is a very important issue that needs addressing. I am willing to implement a fix. Could you point me in the right direction?

@KotlinIsland
I'm sorry. I haven't looked into it yet, I will investigate this weekend.

@koxudaxi This field isn't editable (#379), Can we just not save it to the XML file?

@KotlinIsland
detectRuffExecutable writes the python path in the xml file by using RuffConfigService.
I can see the path in the xml.

fun detectRuffExecutable(project: Project, ruffConfigService: RuffConfigService, lsp: Boolean): File? {

@State(name = "RuffConfigService", storages = [Storage("ruff.xml")])

image

image

I would recommend against using $PROJECT_DIR$ and instead use $PyInterpreterDirectory$, it would be highly unlikely that a project would include an exe for ruff outside the venv, and some venvs are not within the project dir (poetry)