You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
.rs.api.restartSession() Command no longer allows variables to be referenced #14636
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
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.
@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.
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.
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?
Activity
ronblum commentedon May 2, 2024
@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.
lawbaker commentedon May 2, 2024
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.
ronblum commentedon Jun 13, 2024
Verified that the variables are maintained or removed based on the value of
clean, whether or notcommandis present.One question: In either case,
x + yentered in the Console Pane. However, it doesn't show any results--the sum ifclean = FALSEand the error about a missing variable withclean = TRUE. Moving back because I think that this is incorrect?gtritchie commentedon Jul 4, 2024
Moving back to in-progress; I reverted #14921 due to it failing to link on Windows.
ronblum commentedon Jul 9, 2024
Verified in RStudio Desktop 2024.07.0-daily+303 on Windows 11.