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

R: renv <= 1.0.1 causes an infinite loop when trying to restore on startup #6681

Open
DavisVaughan opened this issue Mar 7, 2025 · 0 comments
Labels
area: kernels Issues related to Jupyter kernels and LSP servers lang: r

Comments

@DavisVaughan
Copy link
Contributor

See #6344 (comment)

Reprex is to clone https://github.com/rladies/rladies.github.io and try and load it in Positron. Note that activate.R has pinned the renv version to 1.0.1 there, an old version.

What follows is my analysis of the problem from #6344


I've determined that for @drmowinckels the problem is that rladies uses a fairly old version of renv in https://github.com/rladies/rladies.github.io/tree/main

The TLDR is that if you just bump the renv version from 1.0.1 -> 1.0.2 here, it will work again:
https://github.com/rladies/rladies.github.io/blob/5f58ce6faa66e27e24baffe2ede1c33f3e52d989/renv/activate.R#L5

(id encourage using renv::upgrade() to get all the way up to latest renv, you may have to do this from rstudio)

(you will have to fully clean out the renv/library/ if you've already restored before, you need to get renv to re-bootstrap itself)


The long answer is that we have specific patches support for renv to avoid letting renv ask the user questions at .Rprofile time before ark is fully started up. We recognize when renv is running through a global option and return "n" rather than showing an input prompt to the user, which lets renv return from its renv:::ask() helper function. (For anyone besides renv, we error if menu() or readline() are called during startup)

The problem is that in renv 1.0.1 and below, renv didn't use renv:::ask() in this spot, it used renv:::menu(), and that required that we return "cancel" to this particular question 😢.
https://github.com/rstudio/renv/blob/5dc2fc934867a1b34ec9d1c594dc57d3c9698650/R/load.R#L822

Since we return "n" and that is not a supported option, the menu() call gets into an infinite loop, causing the crash.

To patch this old renv version, we could probably:

  • Continue to detect the renv.autoloader.running global option
  • Also detect if the buffer contains "What do you want to do?" and return "cancel" rather than "n" in that case, as that is specific to renv 1.0.1

It is worth noting that in renv 1.0.8 and above, we have totally fixed this problem by preventing renv from asking the user questions at all, thanks to rstudio/renv#1915.


So here's the state of things:

  • renv < 1.0.2, you get a crash, which we will try and patch if we can
  • renv 1.0.2 -> 1.0.7, you get the 1st image below, from our auto response of "n"
  • renv 1.0.8 and above, you get the 2nd image below, from renv knowing now to ask questions and instead tell the user to renv::restore()
Image Image
@juliasilge juliasilge added lang: r area: kernels Issues related to Jupyter kernels and LSP servers labels Mar 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: kernels Issues related to Jupyter kernels and LSP servers lang: r
Projects
None yet
Development

No branches or pull requests

2 participants