Skip to content

ark: Support a session init hook #697

Open
@jennybc

Description

@jennybc

Follow-up work related to posit-dev/positron#2070 and renv support.

RStudio supports a session init hook that runs after R is fully initialized:

https://github.com/rstudio/rstudio/blob/8ebe5431ca2fb3c9719b70d4fbc45201d226c79c/src/cpp/session/modules/SessionRHooks.hpp#L19

https://github.com/rstudio/rstudio/blob/8ebe5431ca2fb3c9719b70d4fbc45201d226c79c/src/cpp/session/SessionMain.cpp#L857

https://github.com/rstudio/rstudio/blob/8ebe5431ca2fb3c9719b70d4fbc45201d226c79c/src/cpp/session/modules/SessionRHooks.hpp#L36-L39

https://github.com/rstudio/rstudio/blob/8ebe5431ca2fb3c9719b70d4fbc45201d226c79c/src/cpp/session/modules/SessionRHooks.R#L16-L31


Good resource on R startup: https://rstats.wtf/r-startup


People typically use this sort of hook to schedule startup-ish code that makes use of, for example, readline(), menu() or rstudioapi. Our immediate use case here in Positron is related to renv, where it would be nice to schedule the "hey you need to do renv::restore(); shall we do it? interaction for execution after R has been fully stood up.


GitHub search for uses of rstudio.sessionInit:

https://github.com/search?q=rstudio.sessionInit&type=code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions