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

R: configure default runtime #6207

Open
Tracked by #6202
sharon-wang opened this issue Jan 31, 2025 · 1 comment
Open
Tracked by #6202

R: configure default runtime #6207

sharon-wang opened this issue Jan 31, 2025 · 1 comment
Assignees
Labels
area: runtimes Issues related to Language Runtimes area: workbench Issues related to Workbench category. enhancement New feature or request lang: r theme: runtime startup

Comments

@sharon-wang
Copy link
Member

sharon-wang commented Jan 31, 2025

Implementation Summary

Create an equivalent option to python.defaultInterpreterPath for R.

A new option will be added to a default path to an R binary which will be used for newly opened workspaces. The user can configure this option via the Settings UI or via the user settings.json directly. As such, these settings will be applicable at the workspace and/or user scopes, and can be preset by a workbench admin via positron-user-settings.json.

add positron.r.interpreters.default settings option

  • a String; a single path to an R interpreter binary
  • Draft description: Path to default R binary to use when extension loads up for the first time, no longer used once an interpreter is selected for the workspace.
    • this description reuses the Python option python.defaultInterpreterPath's description
  • Default: null; or R (which R) -- this would be consistent with python.defaultInterpreterPath which has python as the default

Mockup of Settings UI

Image

Difference between this issue and #2659

This issue is distinct from #2659 in that this issue is about establishing a default interpreter for any general workspace a user opens, whereas #2659 focuses on specifying a default interpreter for a specific workspace.

this issue issue #2659
if I open a workspace I have not previously opened in Positron, I want interpreter /path/to/my/interpreter/4.3.0/R to be used by default, until I change it to something else when I open my workspace my-data-analysis, I want to ensure that the interpreter R 4.3.0 is the affiliated runtime that is started each time

Implementation Considerations

What if a user specifies invalid paths, the interpreters or directories don’t exist, or something else is wrong with the user’s input in settings?

  • If any of these are invalid for any reason (i.e. broken path, does not exist), we will indicate as such in logs and/or via Notification toasts at the time of discovery, as there isn’t very robust input validation in the Settings UI.
  • May need some additional UI/notifications to cover the case where this causes discovery to find nothing. “Could not find any interpreters included in the setting python.interpreters.override. Would you like Positron to try again, without the setting?”
    • We have a Positron core toast “no interpreters found”, but maybe not for Python or R yet

What if a user has interpreter includes, excludes AND overrides specified?

  • Overrides will take precedence over any specified includes and excludes, so if a user has all three specified or one of includes/excludes specified along with overrides, we will only use the overrides.
  • How to surface this to the user?
    • INVESTIGATE: can we update the setting descriptions for includes/excludes to indicate that the override option will take precedence when the override option is set?
    • include in the setting description that includes/excludes will be overridden by overrides; and in overrides description, include that it will replace any specifications in includes/excludes.

Example scenario

  • Possible Interpreters:
    • /path/to/a/python/1
    • /path/to/a/python/2
    • /path/to/a/python/3
    • /path/to/pyenv/python/1
    • /path/to/global/python
  • Options
    • exclude: /path/to/global/python, /path/to/a/python/3
    • include: /path/to/a/python/2
    • override: /path/to/a/python/1
  • Result of discovery:
    • /path/to/a/python/1

How does the default path option work if the workspace-level setting is configured for a collaborative project?

  • Paths to binaries are specific to a machine. For collaborative projects that are accessed on various desktop machines, the default path option doesn't really make sense as each person could have R installed in different locations. For a managed environment, the path to R will be configured by an admin on the server/in a container, and as such will be consistent across users who access Positron via a web interface.
  • We can have handling that tries the default path and if it doesn't exist, then we fallback to which R
@sharon-wang sharon-wang added this to the 2025.03 Pre-Release milestone Feb 10, 2025
@sharon-wang sharon-wang added enhancement New feature or request area: workbench Issues related to Workbench category. lang: r area: runtimes Issues related to Language Runtimes theme: runtime startup labels Feb 10, 2025
sharon-wang added a commit that referenced this issue Mar 11, 2025
### Summary

- addresses #6207 and
#6208
- introduces new setting `positron.r.interpreters.default`
- the default interpreter set with `positron.r.interpreters.default`
will be recommended for the workspace with Implicit startup behaviour,
as part of runtime startup before discovery takes place
- allow `positron.r.customBinaries` and `positron.r.customRootFolders`
to start with aliased home directory `~`
- relative paths are still ignored, but now we will log that we are
ignoring them
    - docs PR: posit-dev/positron-website#55

#### Settings UI

<img width="725" alt="image"
src="https://github.com/user-attachments/assets/a4b07d31-5ab1-4d42-a750-f5b563ebed0a"
/>

#### Settings JSON

```json
    "positron.r.interpreters.default": "~/scratch/4.3-arm64/Resources/bin/R"
```

#### R Language Pack Output

```js
2025-03-07 11:15:50.698 [info] R installation discovered: {
  "usable": true,
  "supported": true,
  "reasonDiscovered": [
    "Found in a location specified via user settings"
  ],
  "reasonRejected": null,
  "binpath": "/Users/sashimi/scratch/4.3-arm64/Resources/bin/R",
  "homepath": "/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources",
  "semVersion": {
    "options": {},
    "loose": false,
    "includePrerelease": false,
    "raw": "4.3.3",
    "major": 4,
    "minor": 3,
    "patch": 3,
    "prerelease": [],
    "build": [],
    "version": "4.3.3"
  },
  "version": "4.3.3",
  "arch": "arm64",
  "current": false,
  "orthogonal": true,
  "default": true // <-- this is new as of this PR
}
```

- search for `[recommendedWorkspaceRuntime]` to see if the default
interpreter path was recommended for the workspace

### Release Notes

#### New Features

- Default R interpreter in Positron can now be configured via settings
(#6207)
- `positron.r.customRootFolders` and `positron.r.customBinaries` paths
can now start with tilde `~`

### QA Notes

- the default interpreter should not be started by default -- it should
show up as the first option in the interpreter list though!

---------

Signed-off-by: sharon <[email protected]>
Co-authored-by: Jennifer (Jenny) Bryan <[email protected]>
@sharon-wang
Copy link
Member Author

sharon-wang commented Mar 11, 2025

Implemented in #6621 -- please see QA notes there! #6208 is is essentially an implementation detail that can't really be tested separately from this issue, so I've closed it as completed.

Draft docs on how to use this new setting:

positron.r.interpreters.default

To highlight a specific R interpreter as the default for new workspaces, use this setting to specify the path to the R interpreter.

Setting description

Specifies the absolute path to the default R binary to use for new workspaces. This setting no longer applies once a user selects an R interpreter for the workspace.

Example

If the preferred default R interpreter is installed in /opt/R/4.2.0/bin/R, set the default interpreter path as follows:

"positron.r.interpreters.default": "/opt/R/4.2.0/bin/R"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: runtimes Issues related to Language Runtimes area: workbench Issues related to Workbench category. enhancement New feature or request lang: r theme: runtime startup
Projects
None yet
Development

No branches or pull requests

1 participant