HenrikBengtsson / startup

:wrench: R package: startup - Friendly R Startup Configuration
https://henrikbengtsson.github.io/startup/
163 stars 5 forks source link

RStudio Console: Calling readline() during startup causes RStudio to load .RData! #80

Closed HenrikBengtsson closed 4 years ago

HenrikBengtsson commented 4 years ago

Related to Issues #79. With

message(".Rprofile ...")
message("Press ENTER to continue: ")
ans <- readline()
message("You entered: ", sQuote(ans))
message(".Rprofile ... done")

in ./.Rprofile and an existing ./.RData data file, will result in the RStudio Console loading the ./.RData file when readline() is called, not after the .Rprofile finishes;

.Rprofile ...
Press ENTER to continue: [Workspace loaded from ~/rstudio-tests/.RData]

> abc
You entered: ‘abc’
.Rprofile ... done
>

See also

Reported to https://github.com/rstudio/rstudio/pull/5844

HenrikBengtsson commented 4 years ago

FWIW, calling:

utils::menu(c("yes", "no"), graphics = FALSE, title = "Yes or no?")

during startup will also trigger .RData to be loaded.

HenrikBengtsson commented 4 years ago

Using

utils::menu(..., graphics = TRUE)
utils::select.list(..., graphics = TRUE)

seems to work, but it also blocks the RStudio GUI to fully load until after the GUI prompt has been answered.

HenrikBengtsson commented 4 years ago

For the record, it's not possible to use rstudioapi:::showQuestion() during startup because RStudio is not yet fully initiated and we'll get "Error: RStudio not running".

HenrikBengtsson commented 4 years ago

Ended up using a tcltk::tk_messageBox().