posit-dev / positron

Positron, a next-generation data science IDE
Other
2.55k stars 80 forks source link

Newly created pyenv envs not getting picked up by Positron #3944

Closed testlabauto closed 1 month ago

testlabauto commented 3 months ago

Positron Version: 2024.07.0 (Universal) build 21

Steps to reproduce the issue:

  1. Create a new pyenv env such as pyenv install -v 3.12.1
  2. Completely restart positron
  3. Look for new version

What did you expect to happen?

Expected new version to be available for use

Were there any error messages in the output or Developer Tools console?

I do not see any.

jonvanausdeln commented 3 months ago

I can also reproduce this on Windows (I even rebooted the machine)

Additionally, I see this in terminal in Positron:

image

But in my normal windows terminal I see:

image

Note - my newly added pyenv version was 3.10.10

timtmok commented 3 months ago

Is it not visible in the interpreter selector or when running the Python: Select Interpreter command?

testlabauto commented 3 months ago

@timtmok I am not seeing new pyenvs via the selector and not seeing them with the Python: Select Interpreter command.

jonvanausdeln commented 3 months ago

I just did an uninstall.. and deleted %APPDATA%\Roaming\Positron... then installed. Now I'm seeing all of the interpreters

I used the wiki instructions for "Resetting everything"

timtmok commented 3 months ago

I happen to not see them in the selector but it does show up when using the command. Then it shows in the selector. I'm using 2024.07.0 (Universal) build 17.

testlabauto commented 3 months ago

Oh, you are correct, @timtmok ... I can get to them from the command and that makes them show up in the selector.

seeM commented 3 months ago

If it's visible in the command but not in Positron, that's still a bug. It means that the Python extension discovers a new interpreter, but we aren't correctly notifying Positron.

The code responsible is here: https://github.com/posit-dev/positron/blob/bbacfc47a21fe71dbd62bffd2752e0a7b2042578/extensions/positron-python/src/client/positron/manager.ts#L69

For comparison: when you select an interpreter via the command, the code that then registers it with Positron is here: https://github.com/posit-dev/positron/blob/bbacfc47a21fe71dbd62bffd2752e0a7b2042578/extensions/positron-python/src/client/positron/manager.ts#L81

isabelizimm commented 2 months ago

This is happening since the quickpick (cmd+shift+p -> Python: Select Interpreter) refreshes the interpreter list the first time you open it up; subsequent refreshes have to be manually triggered.

So, a repro would look something like

  1. Create new pyenv in terminal pyenv virtualenv 3.11.4 my-new-env See that it does not show up in Positron interpreter selector, since no refresh has been triggered.
  2. Open Command Palette -> Python: Select Interpreter quickpick to trigger refresh. See interpreter in Positron interpreter and command palette selector.
  3. Create another pyenv in terminal pyenv virtualenv 3.11.4 my-new-env-2. Cannot see in quickpick OR Positron interpreter dropdown.
  4. Click refresh button in quickpick. See interpreter in quickpick and Positron interpreter dropdown

https://github.com/posit-dev/positron/blob/bbacfc47a21fe71dbd62bffd2752e0a7b2042578/extensions/positron-python/src/client/interpreter/configuration/interpreterSelector/commands/setInterpreter.ts#L197-L210

To keep parity between these lists, a few options are:

  1. Do not refresh interpreters on first quickpick open post-discovery. This would force users to manually refresh from the quickpick each time they would like to see a new interpreter, but the lists in each location would always be the same. It would be nice to have the discovery refresh button available in the Positron interpreter dropdown, imo
  2. Refresh when users click the ... in the Positron interpreter selector (and always refresh the quickpick when opened), which might be slow.

Related: https://github.com/posit-dev/positron/issues/2003

seeM commented 2 months ago

@isabelizimm could we trigger a refresh on extension load, and maybe in that case the interpreter picker won't trigger another one?

I agree that it could be helpful to have a way to manually refresh/redo discovery in Positron via the UI, which we could track separately.

jonvanausdeln commented 1 month ago

Verified Fixed

Positron Version(s) : 2024.09.0-1 OS Version(s) : Windows 11, MacOS 14

Test scenario(s)

After installing new pyenv, it appears in list after any of these:

Same is true for uninstalling a pyenv version