You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
R: Create a check_installed()-type of experience #1629
The R extension currently uses some R packages unconditionally. Perhaps that won't be true forever, i.e. we'll have a system for opting out (or in).
It feels like we need an official way of saying: "hey, you need to install/update package X before I can fulfill your request; would you like to do so now?"
This is something we should do pretty similarly to RStudio, which has a dependency manager and a JSON file that declaratively sets out the dependencies:
Having the dependencies defined in this way makes it possible for us to autogen documentation describing exactly which packages we depend upon and at what versions, which was something admins asked us for constantly until we provided it.
A big downside of this approach is that they can get out-of-sync with what actually happens when users install packages. We record the minimum-required versions of packages, and try to record those package dependencies as well. However, as packages are updated, they might require new dependencies, or drop old dependencies.
This leads to scenarios where attempts to create R Markdown documents will require installation of the markdown package, because older versions of the rmarkdown package required it, and we had recorded that dependency.
This trips up users since tools like renv might infer a different dependency list than RStudio will, and users will be confused as to why RStudio demands the installation of packages which, strictly-speaking, aren't required.
All of this is to say: if we implement something similar in Positron, we should be cognizant of these sorts of issues and see if we can do better.
* Shows a simple modal dialog prompt. This is a simpler variant of
* `showModalDialogPrompt` for convenience. If you need to be able to force
* the dialog to close, use the `showModalDialogPrompt` method instead.
*
*
* @param title The title of the dialog
* @param message The message to display in the dialog
* @param okButtonTitle The title of the OK button (optional; defaults to 'OK')
* @param cancelButtonTitle The title of the Cancel button (optional; defaults to 'Cancel')
*
* @returns A promise that resolves to true if the user clicked OK, or false
* if the user clicked Cancel.
*/
showSimpleModalDialogPrompt(title: string,
message: string,
okButtonTitle?: string,
cancelButtonTitle?: string): Promise<boolean>;
}
The above is available inside Positron but is not exposed via the extension API, so part of the work would be exposing it so we could use it in our extensions. That'd be a worthy investment as there are plenty of other places we'll wind up using it.
Now that #1816 is merged in, we have a way to tell the user they need a certain package and ask them if they want to install it. ✅
What we still need is a way to check if the package is installed, from the extension host. I think the best option is going to be running the R code pkg %in% base::.packages(all.available = TRUE) the way that amalthea does for diagnostics. How can we get the output from this, to decide what happens next?
We want to run this behind the scenes, much like the formatter, so something like the execute method of the LanguageRuntime is a better fit than the executeCode() API (always runs in the console). However, that only returns void right now.
Could I get amalthea to run this R code and return the result? Via what approach?
There is a reasonable chance that a package is not installable at all -- this happens a lot in heavily regulated environments with limited/no access to public package repositories. It doesn't have to be part of this PR, but we will probably want the install check to indicate whether the requested package/version is available. If unavailable, we can save the user the frustration of trying to install it.
Let's come back and add that functionality as well.
I've moved this to the final review category, but maybe the best way for someone to achieve that final review would be to use the new checkInstalled runtime method in a different spot, like for devtools or testthat somewhere.
I have successfully used this enough that I'm going to close it as completed. This gave me some ideas about making checkInstalled() easier to use throughout positron-r, which are playing out in #1952. I will also open a new issue about what happens when the target package is installed but it doesn't meet the minimum version requirement.
Activity
jmcphers commentedon Oct 18, 2023
This is something we should do pretty similarly to RStudio, which has a dependency manager and a JSON file that declaratively sets out the dependencies:
https://github.com/rstudio/rstudio/blob/main/src/cpp/session/resources/dependencies/r-packages.json
Having the dependencies defined in this way makes it possible for us to autogen documentation describing exactly which packages we depend upon and at what versions, which was something admins asked us for constantly until we provided it.
https://docs.posit.co/ide/server-pro/reference/r_package_dependencies.html
kevinushey commentedon Oct 19, 2023
A big downside of this approach is that they can get out-of-sync with what actually happens when users install packages. We record the minimum-required versions of packages, and try to record those package dependencies as well. However, as packages are updated, they might require new dependencies, or drop old dependencies.
This leads to scenarios where attempts to create R Markdown documents will require installation of the
markdownpackage, because older versions of thermarkdownpackage required it, and we had recorded that dependency.rstudio/rstudio#9861
This trips up users since tools like
renvmight infer a different dependency list than RStudio will, and users will be confused as to why RStudio demands the installation of packages which, strictly-speaking, aren't required.All of this is to say: if we implement something similar in Positron, we should be cognizant of these sorts of issues and see if we can do better.
jennybc commentedon Oct 27, 2023
Notes re: initial implementation
It will be illuminating to consult how the Python extension handles the need for ipykernel. That happens here:
https://github.com/posit-dev/positron-python/blob/main/src/client/common/installer/productInstaller.ts
Prefer our own modal dialogs over VS Code's. Consult what was added to support shutdown work:
positron/src/vs/workbench/services/positronModalDialogs/common/positronModalDialogs.ts
Lines 61 to 79 in 39d4c76
juliasilge commentedon Nov 13, 2023
In amalthea, we already have a way to check for whether a package is installed, for diagnostics.
juliasilge commentedon Nov 17, 2023
Now that #1816 is merged in, we have a way to tell the user they need a certain package and ask them if they want to install it. ✅
What we still need is a way to check if the package is installed, from the extension host. I think the best option is going to be running the R code
pkg %in% base::.packages(all.available = TRUE)the way that amalthea does for diagnostics. How can we get the output from this, to decide what happens next?executemethod of theLanguageRuntimeis a better fit than theexecuteCode()API (always runs in the console). However, that only returnsvoidright now.juliasilge commentedon Dec 8, 2023
As @jmcphers says in #1930:
Let's come back and add that functionality as well.
juliasilge commentedon Dec 11, 2023
I've moved this to the final review category, but maybe the best way for someone to achieve that final review would be to use the new
checkInstalledruntime method in a different spot, like for devtools or testthat somewhere.jennybc commentedon Dec 12, 2023
👆 OK @juliasilge I will create more usage of this in the testing feature.
jennybc commentedon Dec 15, 2023
I have successfully used this enough that I'm going to close it as completed. This gave me some ideas about making
checkInstalled()easier to use throughout positron-r, which are playing out in #1952. I will also open a new issue about what happens when the target package is installed but it doesn't meet the minimum version requirement.