Skip to content

Conversation

Danielkonge
Copy link

I tried adding a search for a conda interpreter.

Note: I am not sure if using CONDA_PREFIX is the best way to do this, but it was the easiest way I found to find the correct path (conda activate <venv> doesn't set VIRTUAL_ENV). Also, I changed read_link to canonicalize since the read_link code didn't seem to work here.

I am not sure why exactly, but I think it might be because the symlinks were local (i.e. something like python -> python3.11) and the exists check searched in the wrong directory, though I did not check this.

(Side note: I couldn't get the logging to work. Have you tried running with the neovim settings and tried to set logLevel and logFile?)

@LaBatata101
Copy link
Owner

LaBatata101 commented Mar 15, 2025

Thanks for trying it out SithLSP!

(Side note: I couldn't get the logging to work. Have you tried running with the neovim settings and tried to set logLevel and logFile?)

Logs are working fine here in Neovim, could you open an issue?

@LaBatata101
Copy link
Owner

LaBatata101 commented Mar 15, 2025

This probably needs some more work. From what I tested the directory in CONDA_PREFIX doesn't seem to contain an python executable but I don't know if I created the conda enviroment correctly.

We need to find the directory where conda puts the python executable for the current active enviroment.

EDIT: The CONDA_PREFIX directory only contains the python executable when you specify a python version with conda create -n test-conda python=3.xx, so the problem is to find the correct python interpreter when the user doesn't specify the version.

@Danielkonge
Copy link
Author

Logs are working fine here in Neovim, could you open an issue?

I will probably play around with it some more (just started trying out sith-lsp) and make an issue if I can't figure out what I did wrong.

This probably needs some more work. From what I tested the directory in CONDA_PREFIX doesn't seem to contain a python executable but I don't know if I created the conda enviroment correctly.

We need to find the directory where conda puts the python executable for the current active enviroment.

Ah, I always specify the version so I hadn't noticed this. I think it can be hard to find the conda python executable via env then. I guess the easiest solution is to use command calls like which python then (on Linux/macOS - it seems to be where python on Windows, but I can't check that). This should return the correct python path (though we still might need to resolve links).

Would you be fine with using something like std::process::Command::new("which").arg("python") here?

@LaBatata101
Copy link
Owner

Ah, I always specify the version so I hadn't noticed this. I think it can be hard to find the conda python executable via env then. I guess the easiest solution is to use command calls like which python then (on Linux/macOS - it seems to be where python on Windows, but I can't check that). This should return the correct python path (though we still might need to resolve links).

Would you be fine with using something like std::process::Command::new("which").arg("python") here?

You can still use CONDA_PREFIX and check if there's a bin directory there and get the python executable. If there's not, fallback to a system wide search with try_to_resolve_python_path.

@LaBatata101 LaBatata101 force-pushed the main branch 4 times, most recently from 9ff167a to 08b9485 Compare April 22, 2025 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants