Prompt to install missing R packages doesn't appear in RStudio

I saw in this this blog post that it's possible to let RStudio prompt the user to automatically install missing packages. The option is in the menu under Tools -> Global Options -> Code -> Diagnostics and then enable the checkbox Prompt to install missing R packages discovered in R source files.

However, I've got the option enabled but as far as I can see there is no prompt. See screenshot below.

What am I doing wrong here? I'm working on a single script file, but I assume that doesn't matter correct? Also I've edited and saved it. Does it rely on a combination with another option maybe? Or is the prompt moved to a different screen that's not visible at the moment?

FYI this is my info: RStudio v1.4.1717 (Windows 10) and I suspect it's the same as this thread.

I tried in on the most recent build RStudio 2022.07.0 Build 548, 64-bit, Windows 10, but the prompt still doesn’t appear. Here are the steps to reproduce.

  • Create a new R Script (Ctrl + Shift + N)
  • Paste the code below
  • Select all (ctrl + A)
  • Run selection (ctrl + Enter)

google <- tq_get(x = "GOOG")


As far as I can see there's no prompt or dialog to install the tidyquant library and the output is just this:


Error in library(tidyquant) : there is no package called ‘tidyquant’

google <- tq_get(x = "GOOG")

Error in tq_get(x = "GOOG") : could not find function "tq_get"


Error: object 'google' not found

I know how to install packages, but I want our users (medical researchers) to automatically get a prompt for any missing packages when they are working with our R scripts.

If you:

  • Save the R Script
  • Close the R Script
  • Open the R Script again

Do you see the prompt? (My knowledge of this feature isn't perfect but some diagnostics only work on saved files that have a location on disk.)

Also, try this:


Does it succeed? Do you see tidyquant in the table returned? (This is the database used by the diagnostic engine to determine whether a package is installable or not.)

Ah yes, It doesn't work on new un-saved scripts. The prompt does appear when I save the file :smiley::+1:

Also fyi I do see the tidyquant in the returned table so that was not the problem