How to set the default startup project in rocker/tidyverse

I have a Dockerfile derived from rocker/tidyverse. How can I set the default project to be loaded at startup? Assume myproj.Rproj in the default RStudio folder.

I tried to put rstudioapi::openProject(".") in my .Rprofile but I get an error because RStudio is not yet running. So I could change my question to: how to run a script when Rstudio (from Rstudio server) has been started?

Use this in .Rprofile

setHook("rstudio.sessionInit", function(newSession) {
  if (newSession && is.null(rstudioapi::getActiveProject()))
    rstudioapi::openProject(".")
}, action = "append")

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.