Skip to content

Allow rstudioapi to work inside child R sessions #4490

Closed

Description

@jmcphers

Currently, rstudioapi does not work inside child R sessions -- jobs, R markdown renders, etc. This is because all of the functions it calls exist only in the parent R session.

It would be very useful to be able to invoke rstudioapi functions inside child R sessions. For example, we could use them:

  • for knitr to report knit progress from its child R session
  • for RStudio jobs to orchestrate actions in the parent R session (e.g. open a tab with results when complete)
  • for learnr and other Shiny-based apps to drive the IDE without blocking the R console
  • and probably lots of other scenarios

This could take the form of exposing the whole API generically with some kind of mechanism that marshals function arguments and return values, or creating a subset of the API specifically intended for child processes with different signatures/semantics.

Activity

  1. garrettgman commented on Jun 4, 2019

    @garrettgman
    Member

    This feature request is an important component of the plan we came up with on 5/22/19 to make an IDE friendly tutorial format.

  2. added this to the v1.3 milestone on Sep 5, 2019
  3. kevinushey commented on Sep 25, 2019

    @kevinushey
    Collaborator

    This has now been implemented -- rstudioapi functions, when executed within R child processes launched by RStudio, should now work and communicate back through the main RStudio session.

  4. schloerke commented on Sep 25, 2019

    @schloerke
    Contributor

    Wow! Thank you!

  5. modified the milestones: v1.3, v1.3-preview on Dec 17, 2019
  6. tmcduff commented on Jan 21, 2020

    @tmcduff

    Version 1.3.749

  7. AshesITR commented on Apr 30, 2020

    @AshesITR

    Is there any way to use this within a future?
    Apparently, those processes aren't spawned as child processes.

    Setting up a different future plan which does spawn child processes would be fine with me as well.

    library(future)
    plan(multisession)
    value(future(rstudioapi::isAvailable()))
    #> [1] FALSE
    value(future(rstudioapi::isAvailable(child_ok = TRUE)))
    #> [1] FALSE

    (running on windows)

    Created on 2020-04-30 by the reprex package (v0.3.0)

  8. kevinushey commented on Apr 30, 2020

    @kevinushey
    Collaborator

    No, unfortunately this isn't yet possible -- this is only for child processes normally launched by RStudio, not arbitrary child processes from R or R packages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions