koxudaxi / ruff-pycharm-plugin

PyCharm plugin for ruff. This plugin provides reformat code using ruff.
MIT License
196 stars 9 forks source link

ruff executable not found in conda environment on Linux #308

Closed psarka closed 9 months ago

psarka commented 10 months ago

Describe the bug ruff executable not found in conda environment on Linux

To Reproduce

  1. Wipe existing JetBrains tools & configs and install fresh Pycharm Pro (2023.2.4 at the time of filing this bug)
  2. Install this plugin (0.0.25 at the time of filling this bug)
  3. Create a new conda environment (in my case using micromamba, but any distro should work) mamba create -n ruff ruff
  4. Open some project and set ruff as local environment

Then

  1. ruff is not detected by the plugin (see screenshot)
  2. Pycharm sees ruff installed (see screenshot)
  3. Clicking aut-detect ruff does nothing (and fair enough, I don't have a global ruff)
  4. Entering /home/psarka/mambaforge/envs/ruff/bin/ruff to Project Specific ruff executable does nothing, and disappears when I click OK and reopen plugin settings
  5. Restarting Pycharm does nothing
  6. No messages are ever displayed

Expected behavior ruff to be detected

Screenshots image image

Environments (please complete the following information):

Additional context I can set /home/psarka/mambaforge/envs/ruff/bin/ruff to Global ruff executable and then it works (phew! I really need it!)

koxudaxi commented 9 months ago

@psarka I'm sorry for the late response. Thank you for your sponsorship.

I would like to reproduce it, but I don't have conda on this machine and am installing it now. One thing that concerns me is that the conda utility to find the package path that this plugin uses is deprecated to. If you can find a better way to find a conda environment, your problem might be solved.

https://github.com/koxudaxi/ruff-pycharm-plugin/actions/runs/7070462990/job/19247160266#step:11:225

psarka commented 9 months ago

Thanks for finding time to look at this!

I'm guessing my case hits this branch: https://github.com/koxudaxi/ruff-pycharm-plugin/blob/3a02cfcb882cac902ed44eb423519b82e2d01f07/src/com/koxudaxi/ruff/Ruff.kt#L157C1-L159C18

I wonder what does sdk.homeDirectory resolve to? The paths to ruff in my example environment looks like this:

(test-environment) psarka@xps:~$ which ruff
/home/psarka/miniforge3/envs/test-environment/bin/ruff

If sdk.homeDirectory resolves to /home/psarka/miniforge3/envs/test-environment/, then you probably don't need the .parent there.

koxudaxi commented 9 months ago

@psarka sdk.homeDirectory resolves to {pyhton_dir}/bin/python 😅 image image

koxudaxi commented 9 months ago

I will check it in the windows too.

koxudaxi commented 9 months ago

In Windows, it's same result imagea

koxudaxi commented 9 months ago

OK, I understand the platform difference.

koxudaxi commented 8 months ago

@psarka I released the fixed version as v0.0.28. Could you please check it?

psarka commented 8 months ago

Hi, sorry for the lag, yes, it works, thank you! :pray: