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

User configurable R location #5205

Merged
merged 4 commits into from
Oct 30, 2024
Merged

User configurable R location #5205

merged 4 commits into from
Oct 30, 2024

Conversation

jennybc
Copy link
Member

@jennybc jennybc commented Oct 29, 2024

Addresses #2235

Adds 2 configuration points:

  • positron.r.customRootFolders is an array. Each entry is a folder that is searched for 1 or more R installations.
  • positron.r.customBinaries is an array. Each entry is the path to a specific R binary.

QA Notes

It's hard to get into a position where this configuration comes into play, because you have to make sure that four methods of automatic discovery won't work. I'm focusing on Windows because that's the main OS that drives the need for this.

  • Install R at a non-standard location. This will have to be via the CRAN installer since rig doesn't give you any choice about this. Therefore I removed my rig-installed released version of R and re-installed released R with the CRAN installer below C:/nonstandardRLocation/. Make sure to uncheck the box to write to the registry! If you forget or you're doing this with an existing installation, you can remove the registry keys with C:/nonstandardRLocation/R-4.4.1/bin/x64/RSetReg.exe /U (note the /U argument for unsetting keys). All R installations on Windows ship with this executable for setting/unsetting registry keys.
  • Now use rig (or other means) to make some other R version the current version. In my setup, R 4.2.3 and 4.3.3 are good candidates for the new current version of R, e.g. rig default 4.3.3.
  • Make sure this R installation is not on the PATH.
  • Fire up Positron. The interpreter drop down should not include this R version that is
    • not in the standard root folder for R, i.e. not in C:/Program Files/R nor in C:/Users/<Username>/AppData/Local/Programs/R
    • not the current version of R
    • not recorded in the registry
    • not on the PATH

Use the command palette to do Preferences: Open Settings. Go to Extensions > R > Positron R Language Pack (advanced) and do each of these, in turn:

  • In Custom Binaries, add the path to the nonstandard R binary, e.g. C:/nonstandardRLocation/R-4.4.1/bin/x64/R.exe
  • In Custom Root Folders, add the parent folder of the nonstandard R version, e.g. C:/nonstandardRLocation

Fire up Positron again. Either of these settings should make the nonstandard installation appear in the interpreter dropdown.

Other things that can be noticed in the Positron R output channel:

  • In the presence of custom binaries, you'll see something like this:

    2024-10-30 01:03:07.761 [info] User-specified R binaries:
    [
      "C:/nonstandardRLocation/R-4.4.1-bin/x64.R.exe"
    ]
    
  • In the presence of a custom root folder, you'll see something like this:

    2024-10-30 00:56:15.137 [info] User-specified directories to scan for R installations:
    [
      "C:/nonstandardRLocation"
    ]
    

registry = 'Windows registry',
/* eslint-disable-next-line @typescript-eslint/naming-convention */
PATH = 'PATH'
PATH = 'PATH',
user = 'user-specified directory'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just continuing to lay groundwork that will be helpful when tackling #1397.

cachedRBinary = await findRBinaryFromPATH();
return cachedRBinary;
}

let cachedRBinaryFromPATH: string | undefined;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an unrelated improvement. Part of continuing effort to reduce rediscovery and repetition in the output channel.

@jennybc jennybc marked this pull request as ready for review October 30, 2024 05:08
Copy link
Contributor

@juliasilge juliasilge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From a code perspective and how the options are presented to users, this is looking great!

I did just spend a bit of time trying to install R in a non-standard location on my dev machine AND FAILED 😆 so let's get this merged in and available for testing in a broader set of circumstances.

@jennybc jennybc merged commit 465058d into main Oct 30, 2024
3 checks passed
@jennybc jennybc deleted the user-configurable-r-location branch October 30, 2024 16:45
@github-actions github-actions bot locked and limited conversation to collaborators Oct 30, 2024
Comment on lines -254 to -256
// @kevinushey likes to install R here because it does not require administrator
// privileges to access
'C:\\R',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heads up @kevinushey: as previously discussed, you can now configure this location via the new positron.r.customRootFolders configuration point, available in the advanced section of positron-r's settings.

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

Successfully merging this pull request may close these issues.

2 participants