rstudio / rstudio

RStudio is an integrated development environment (IDE) for R
https://posit.co/products/open-source/rstudio/
Other
4.68k stars 1.09k forks source link

RStudio not able to load installed R version on Windows by default || It always give a pop up to choose between the versions #12695

Closed DeepaReddy2022 closed 7 months ago

DeepaReddy2022 commented 1 year ago

I am trying to Launch the latest version of Rstudio (RStudio 2022.12.0 Build 353) , But whenever I launch Rstudio, Its asking to choose the version. This is the new issue popping up after installing the latest version. image

rstudio_issue

Please help me to make a setting that would avoid this window.

ronblum commented 1 year ago

@DeepaReddy2022 Thank you for raising this! Once you choose a version and click "OK" does RStudio run as expected?

DeepaReddy2022 commented 1 year ago

It runs as expected. But I do not want this window to be showed every time when I open Rstudio. How can I avoid this ?

Do we have any backend code to suppress the upgrades? I tried doing it from the RStudio settings, but these settings are erased after reboot. I want to keep the older version. image

Please let me know if we can comment the code to upgrade the version - in the backend.

tolot27 commented 1 year ago

@DeepaReddy2022 Thank you for raising this! Once you choose a version and click "OK" does RStudio run as expected?

One cause of the problem is that RStudio expects InstallPath at HKEY_LOCAL_MACHINE\SOFTWARE\R-core\R64 but it only exists below the installed versions (i. e. HKEY_LOCAL_MACHINE\SOFTWARE\R-core\R64\4.3.0).

RStudio should read the value of Current Version from HKEY_LOCAL_MACHINE\SOFTWARE\R-core\R (or R64) and use this value as subkey to read InstallPath. After this, at least top option is selected (as shown in the screenshot) and the user just have to click okay.

image

But if just one version of R is installed, RStudio should just use this version as default and should never ask for the version.

kevinushey commented 1 year ago

One cause of the problem is that RStudio expects InstallPath at HKEY_LOCAL_MACHINE\SOFTWARE\R-core\R64

But R does update this registry key. For example, my machine has:

C:\Users\kevin>reg query HKLM\Software\R-Core\R64

HKEY_LOCAL_MACHINE\Software\R-Core\R64
    InstallPath    REG_SZ    C:\R\R-3.5.0
    Current Version    REG_SZ    3.5.0

HKEY_LOCAL_MACHINE\Software\R-Core\R64\3.5.0

Or, similarly:

C:\Users\kevin>reg query HKLM\Software\R-Core\R64 /reg:32

HKEY_LOCAL_MACHINE\Software\R-Core\R64
    InstallPath    REG_SZ    C:\R\R-4.3.0
    Current Version    REG_SZ    4.3.0

HKEY_LOCAL_MACHINE\Software\R-Core\R64\4.2.3
HKEY_LOCAL_MACHINE\Software\R-Core\R64\4.3.0
HKEY_LOCAL_MACHINE\Software\R-Core\R64\4.3.0 beta
github-actions[bot] commented 8 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs, per https://github.com/rstudio/rstudio/wiki/Issue-Grooming. Thank you for your contributions.

tolot27 commented 8 months ago

One cause of the problem is that RStudio expects InstallPath at HKEY_LOCAL_MACHINE\SOFTWARE\R-core\R64

But R does update this registry key. For example, my machine has:

Not necessarily, see https://cran.r-project.org/bin/windows/base/rw-FAQ.html#Does-R-use-the-Registry_003f.

mbedward commented 7 months ago

Is this issue active or being treated as stale? Two Windows 10 machines that I administer both have this problem, i.e. default version of R is not detected because (as @tolot27 says above) the install path is not directly under the HKEY_LOCAL_MACHINE\SOFTWARE\R-core\R64 key but in a sub-key for the R version.

kevinushey commented 7 months ago

@mbedward are you able to test if the issue persists for you in the latest daily builds of RStudio? The Windows builds are here: https://dailies.rstudio.com/rstudio/chocolate-cosmos/electron/windows/

mbedward commented 7 months ago

@kevinushey Thanks. I just tried it with RStudio-2024.04.0-daily-612 and tested with both one or two versions of R installed.

When I launch RStudio by Ctrl-clicking the shortcut to open the dialog for choosing the R version, the option for the system's default version is only enabled when more than one R version is installed. I think that the default version, as read from the registry key, will always be the one most recently installed rather than the latest version number.

If only one version of R is installed the option for the system's default R version is disabled so the user must choose the one and only specific version. This means that if a later R version is subsequently installed, the user must remember to ctrl-click launch RStudio to update the version setting, otherwise RStudio will stick with the earlier R version.

Hope that's useful.

gtritchie commented 7 months ago

the option for the system's default version is only enabled when more than one R version is installed.

@mbedward

So far I can't reproduce this specific behaviour. I'm starting with a clean Windows-11 machine, installed R 4.3.3 with default options (i.e. let it register itself), then first run of RStudio (2024.04.0-daily+641), and the default version is enabled (I can hit the enter key and proceed).

image

It is a bug that we show this dialog at all in this scenario (first run). Pre-Electron versions (e.g. 2022.07 Qt-based) would not show the dialog automatically if a version of R was successfully detected. That was mentioned earlier by @tolot27:

But if just one version of R is installed, RStudio should just use this version as default and should never ask for the version.

I've opened a separate issue to track this specific thing: https://github.com/rstudio/rstudio/issues/14472

gtritchie commented 7 months ago

@DeepaReddy2022 You originally opened this issue to track that the "Choose R installation" dialog was being shown every time you open RStudio on Windows. Is that still happening for you with the current release (e.g. 2023.12.1)?

I'd like to close this issue if that original problem is no longer happening and open a new one (or multiple ones) to track other issues being discussed here.

DeepaReddy2022 commented 7 months ago

@gtritchie Please go ahead and close this ticket.