Skip to content

.rs.api.restartSession() Command no longer allows variables to be referenced #14636

Closed

Description

@lawbaker

System details

RStudio Edition : Desktop
RStudio Version : Chocolate Cosmos (2024.04.0-735)
OS Version      :  Windows OS Build 19045.4291
R Version       :  4.2.3

Steps to reproduce the problem

library(dplyr)

x <- 5
y <- 3

.rs.api.restartSession(command = "x + y", clean = FALSE)

This returns an error: Error in base::try(x + y, silent = TRUE) : object 'x' not found.

In addition, the variables x and y are not loaded into the global environment and packages are not reattached, i.e. isNamespaceLoaded("dplyr") is FALSE

Describe the problem in detail

[Updated after input from @ronblum]

The .rs.api.restartSession() function with option clean = FALSE should reload variables and packages. However, this does not work when command is used.

If command not used then the variables are loaded and packages attached as intended.

I wonder if this is related to the clean option, and somehow specifying command is setting clean = TRUE.

Describe the behavior you expected

When clean = FALSE, I would expect variables and packages to be reloaded.

  • I have read the guide for submitting good bug reports.
  • I have installed the latest version of RStudio, and confirmed that the issue still persists.
  • [NA] If I am reporting an RStudio crash, I have included a diagnostics report.
  • I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.

Activity

  1. added
    new
    on May 1, 2024
  2. ronblum commented on May 2, 2024

    @ronblum
    Contributor

    @lawbaker Thank you for raising this! I'm seeing the objects present when just using
    .rs.api.restartSession(clean = FALSE)
    but when adding the command option
    .rs.api.restartSession(command = "x + y", clean = FALSE)
    the variables are gone.

  3. removed
    new
    on May 2, 2024
  4. lawbaker commented on May 2, 2024

    @lawbaker
    Author

    You're right! It looks like the variables aren't loaded when command is specified. I'll modify the top-level post, since this is clearly unintended behavior.

  5. added this to the Cranberry Hibiscus milestone on May 6, 2024
  6. self-assigned this
    on May 30, 2024
  7. ronblum commented on Jun 13, 2024

    @ronblum
    Contributor

    Verified that the variables are maintained or removed based on the value of clean, whether or not command is present.

    One question: In either case, x + y entered in the Console Pane. However, it doesn't show any results--the sum if clean = FALSE and the error about a missing variable with clean = TRUE. Moving back because I think that this is incorrect?

  8. self-assigned this
    on Jun 13, 2024
  9. gtritchie commented on Jul 4, 2024

    @gtritchie
    Member

    Moving back to in-progress; I reverted #14921 due to it failing to link on Windows.

  10. ronblum commented on Jul 9, 2024

    @ronblum
    Contributor

    Verified in RStudio Desktop 2024.07.0-daily+303 on Windows 11.

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

Metadata

Metadata

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions