-
Notifications
You must be signed in to change notification settings - Fork 92
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
Look on the PATH to discover R installations on Windows #3702
Labels
enhancement
New feature or request
investigate
Needs initial, limited investigation to prioritize
lang: r
os-windows
Windows issue
Milestone
Comments
jmcphers
added
enhancement
New feature or request
os-windows
Windows issue
lang: r
labels
Jun 28, 2024
This was referenced Jul 1, 2024
juliasilge
added
the
investigate
Needs initial, limited investigation to prioritize
label
Jul 5, 2024
jennybc
added a commit
that referenced
this issue
Aug 5, 2024
Addresses #3702 Also related to #3677 and #3868 This PR deals with this situation: * R is installed in a non-default location. * We can't learn about this R installation from the registry (either because registry keys were not written or permissions are keeping us from reading the registry). * The user has arranged for R to be discovered on the PATH. ### QA Notes To experience the before vs. after, you need very specific setup. We're trying to imitate a user with R in a non-default location and no permission to access the registry. To make R discoverable, this user is relying solely on the fact that they've put R on their PATH. If you don't have a completely locked down corporate Windows laptop, follow the instructions below to fake it 😬 Before: in a released version of Positron (or a release built before this PR gets merged), the R version set up as described below WILL NOT be discovered by Positron. After: with this PR, the R version set up as described below WILL be discovered by Positron. You can also see more about discovery in the Positron R Extension output channel. (It is expected that you will see that some R versions are discovered more than once.) You should see new logging messages like this: `2024-08-01 16:19:27.712 [info] Possibly found R on PATH: C:\notADefaultFolder\R-4.2.3\bin\x64\R.EXE.` --- 1. **OS must be Windows**. At least one R version needs to be: 2. **Installed in an unusual place** where Positron will not automatically discover it. TL;DR is to install somewhere other than `C:\Program Files` or `C:\R`. For a more precise definition, here is the [actual code](https://github.com/posit-dev/positron/blob/4a05a525c7da4bb2778490eb6a244e0f4b54ccef/extensions/positron-r/src/provider.ts#L228-L236). For example, I chose to put this non-default R installation in `C:\notADefaultFolder` . This will be easiest to do if you use the CRAN installer directly (so, not using rig). You can get old versions of R here: [Previous releases of R for Windows (r-project.org)](https://cran.r-project.org/bin/windows/base/old/) <img width="588" alt="select-destination" src="https://github.com/user-attachments/assets/9f3a7e90-9630-430a-b70c-4b44278776a7"> 4. **Not recorded as the current version of R in the registry**. Make sure it is NOT stored as the `InstallPath` subkey in these locations: - `HKEY_LOCAL_MACHINE\SOFTWARE\R-core\R64` - `HKEY_LOCAL_MACHINE\SOFTWARE\R-core\R` - `HKEY_CURRENT_USER\SOFTWARE\R-core\R64` - `HKEY_CURRENT_USER\SOFTWARE\R-core\R` - `HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\R-core\R` - `HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\R-core\R64` - `HKEY_CURRENT_USER\SOFTWARE\WOW6432Node\R-core\R` - `HKEY_CURRENT_USER\SOFTWARE\WOW6432Node\R-core\R64` Ways to accomplish this: - Don't let the installer write to the registry. <img width="589" alt="save-version-registry" src="https://github.com/user-attachments/assets/cabee89d-7f34-443d-86f7-a30f41f9294c"> - Manually delete keys via the Registry Editor. - Install some *other* version of R after this one and let *that* version be recorded in the registry as the current version of R. - Use utilities that ship with R: > After installation you can add the Registry entries by running `RSetReg.exe` in a sub-folder of the `bin` folder, and remove them by running this with argument `/U`. Note that this requires administrative privileges unless run with argument `/Personal` and neither sets up nor removes the file associations. 5. **Have its `bin\x64` or `bin` directory on the PATH** (system or user). Neither rig nor the CRAN installer do this, so this has to be done explicitly. For example, the path I added to my user PATH is `C:\notADefaultFolder\R-4.2.3\bin\x64`. There seem to be many ways to do this, but here's what I did: Go to About your PC \> Advanced system settings (in list on the right) \> Environment Variables. Add an entry to `Path` for the user or the system. <img width="531" alt="edit-environment-variable" src="https://github.com/user-attachments/assets/2f03db69-c373-4a8e-9439-7ed6f8258395"> You'll need to restart any shells or maybe log out / log in for this to take effect. Test that this has worked by launching R in a terminal and confirm it's launching the intended version. I verified this in cmd.exe, PowerShell, and Git Bash FWIW. --------- Signed-off-by: Jennifer (Jenny) Bryan <[email protected]> Co-authored-by: Jonathan <[email protected]>
Verified FixedPositron Version(s) : 2024.08.0-5 Test scenario(s)Verified on a normal user account (non-admin) with R installed in several non-standard locations. Before adding to PATH, no R versions discovered. After adding to PATH, all were discovered. Also verified with admin account. And local user PATH vs system PATH. Link(s) to TestRail test cases run or created: |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
enhancement
New feature or request
investigate
Needs initial, limited investigation to prioritize
lang: r
os-windows
Windows issue
Followup from #3677.
Positron enumerates the registry to find R on Windows, which successfully discovers R installations that were installed in the traditional way (i.e. with the R installer). However, it's common on Windows to manually install R someplace else and put it on the
$PATH
.This corresponds to this TODO:
positron/extensions/positron-r/src/provider.ts
Lines 340 to 341 in c929d52
The text was updated successfully, but these errors were encountered: