Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IDE shows error when a venv starter is removed #1449

Closed
t-kalinowski opened this issue Aug 16, 2023 · 1 comment · Fixed by rstudio/rstudio#13541
Closed

IDE shows error when a venv starter is removed #1449

t-kalinowski opened this issue Aug 16, 2023 · 1 comment · Fixed by rstudio/rstudio#13541

Comments

@t-kalinowski
Copy link
Member

t-kalinowski commented Aug 16, 2023

The IDE shows a cryptic error message when probing a broken venv as part of its start up routine:

Restarting R session...

Error in system2(command = python, args = shQuote(script), stdout = TRUE,  : 
  error in running command
Calls: do.call ... <Anonymous> -> python_config -> python_config_impl -> system2
Execution halted
> 

(It's not actually an error, just a warning)

This is a different manifestation of #1441.

reprex:

  1. reticulate:::rm_all_reticulate_state()
  2. install_python()
  3. virtualenv_create() # r-reticulate
  4. unlink("~/.pyenv", recursive = TRUE)
  5. restart R session in the IDE (cmd+shift+0)
@t-kalinowski
Copy link
Member Author

The error message is improved, but the real fix is better done in the IDE.

New warning shown:

Restarting R session...

Error in python_config_impl(python) : 
  Error running '/Users/tomasz/.virtualenvs/r-reticulate/bin/python': No such file.
The Python installation used to create the virtualenv has been moved or removed:
  '/Users/tomasz/.pyenv/versions/3.9.17/bin'
Calls: do.call ... <Anonymous> -> <Anonymous> -> python_config -> python_config_impl
Execution halted
>

The line in the IDE that causes the error to be shown: https://github.com/rstudio/rstudio/blob/ffd3ddbe7b45741a16ccf54d5a72a51c86a99bb6/src/cpp/session/modules/SessionReticulate.R#L2124C1-L2124C69

That surrounding tryCatch() should probably capture and silence errors, (and warning too). If py_discover_config() raises an error, that error shouldn't be shown until the user attempts to initialize Python in the R session.

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 a pull request may close this issue.

1 participant