koxudaxi/ruff-pycharm-plugin

ruff executable not found in conda environment on Linux

psarka opened this issue ยท 8 comments

psarka commented

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):

  • IDE: PyCharm Pro 2023.2.4
  • OS: Ubuntu 22.04
  • Ruff Version 0.1.5
  • Plugin version 0.0.25

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!)

@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

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.

@psarka
sdk.homeDirectory resolves to {pyhton_dir}/bin/python ๐Ÿ˜…
image
image

I will check it in the windows too.

In Windows, it's same result
imagea

OK, I understand the platform difference.

  • Windows
    • {python_dir}/python.exe
    • {python_dir}/Scripts/ruff.exe
  • Linux/macOS
    • {python_dir}/bin/python
    • {python_dir}/bin/ruff

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

Hi, sorry for the lag, yes, it works, thank you! ๐Ÿ™