Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rstudioapi::restartSession() does not clear environment or search in R3.4.4 #95

Closed
vnijs opened this issue Apr 19, 2018 · 11 comments
Closed

Comments

@vnijs
Copy link

vnijs commented Apr 19, 2018

It seems that since R 3.4.4 rstudioapi::restartSession() backs-up (and restores) the current environment and doesn't unload packages. Session > Restart R from the menu does still work as expected. Does Rstudio call a different function? Is there an option to have rstudioapi::restartSession() behave the same as the menu?

FYI settings:

image

@vnijs
Copy link
Author

vnijs commented May 17, 2018

FYI Same issue in R 3.5

@kevinushey
Copy link
Contributor

Thanks for the bug report! I've copied this over to the RStudio repository as we'll need some changes there to support this.

@geotheory
Copy link

This still seems to be unresolved. Is there any intention to offer a genuine session refresh?

> exists('slice')
[1] FALSE
> suppressMessages(require(dplyr, quietly = TRUE))
> iris |> slice(1)
  Sepal.Length Sepal.Width Petal.Length Petal.Width Species
1          5.1         3.5          1.4         0.2  setosa
> rstudioapi::restartSession()

Restarting R session...

> exists('slice')
[1] TRUE
> iris |> slice(1)
  Sepal.Length Sepal.Width Petal.Length Petal.Width Species
1          5.1         3.5          1.4         0.2  setosa

@kevinushey
Copy link
Contributor

Sorry for taking so long to respond.

I think rstudioapi::executeCommand("restartR") should do what you need -- it invokes the same command as the Session -> Restart R would as invoked from the menu.

@vnijs
Copy link
Author

vnijs commented Apr 1, 2022

Thanks @kevinushey! Question: Is it possible to have R(studio) run a user provided command after restart? Like rstudioapi::restartSession(cmd)

@kevinushey
Copy link
Contributor

Unfortunately no, not via that interface.

@vnijs
Copy link
Author

vnijs commented Apr 1, 2022

@kevinushey Should create a new feature request for the combined functionality of rstudioapi::executeCommand("restartR") and rstudioapi::restartSession(cmd)?

@kevinushey
Copy link
Contributor

I think we just need some way to configure restartSession() to behave like the "regular" restart session command.

@vnijs
Copy link
Author

vnijs commented Apr 6, 2022

If restartSession could have the option (or default) to behave like rstudioapi::executeCommand("restartR") but with the option to run commands after running that would be fantastic!

@kevinushey
Copy link
Contributor

I've filed rstudio/rstudio#11378 for us to follow up this extension on the RStudio side.

@benfarmer05
Copy link

Hello, I am trying right now to run .rs.restartR() on an M1 Macbook 2020 (RStudio Version 2024.04.2+764 (2024.04.2+764)), and it does not properly clear variables or loaded packages. I have to run rstudioapi::executeCommand("restartR") to achieve that functionality. I am cross-posting this in rstudio/rstudio#14230

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants