Repository navigation
Description
Here's Positron's current definition of ILanguageRuntimeMetadata
positron/src/vs/workbench/services/languageRuntime/common/languageRuntimeService.ts
Lines 493 to 538 in 0c8a8b6
| /* ILanguageRuntimeMetadata contains information about a language runtime that is known | |
| * before the runtime is started. | |
| */ | |
| export interface ILanguageRuntimeMetadata { | |
| /** The path to the kernel. */ | |
| readonly runtimePath: string; | |
| /** A unique identifier for this runtime; usually a GUID */ | |
| readonly runtimeId: string; | |
| /** The name of the language that this runtime can execute; e.g. "R" */ | |
| readonly languageName: string; | |
| /** The internal ID of the language that this runtime can execute; e.g. "r" */ | |
| readonly languageId: string; | |
| /** The version of the language in question; e.g. "4.3.3" */ | |
| readonly languageVersion: string; | |
| /** The Base64-encoded icon SVG for the language. */ | |
| readonly base64EncodedIconSvg: string | undefined; | |
| /** The identifier of the extension that provides the language support. */ | |
| readonly extensionId: ExtensionIdentifier; | |
| /** | |
| * The fully qualified name of the runtime displayed to the user; e.g. "R 4.2 (64-bit)". | |
| * Should be unique across languages. | |
| */ | |
| readonly runtimeName: string; | |
| /** | |
| * A language specific runtime name displayed to the user; e.g. "4.2 (64-bit)". | |
| * Should be unique within a single language. | |
| */ | |
| readonly runtimeShortName: string; | |
| /** The internal version of the runtime that wraps the language; e.g. "1.0.3" */ | |
| readonly runtimeVersion: string; | |
| /** The runtime's source or origin; e.g. PyEnv, System, Homebrew, Conda, etc. */ | |
| readonly runtimeSource: string; | |
| /** Whether the runtime should start up automatically or wait until explicitly requested */ | |
| readonly startupBehavior: LanguageRuntimeStartupBehavior; | |
| } |
Let's focus on:
/** The path to the kernel. */
readonly runtimePath: string;
Over in the R extension, we keep re-discovering that, for R specifically, it would be really handy to hold on to TWO paths: the "home" path and the path to the binary.
Inside positron-r, sometimes we need one, sometimes we need the other, sometimes this even varies across OSes, and the way to get home path from bin path (or vice versa) can also vary across OSes.
We already obtain both of these paths when instatiating an RInstallation. The problem is that only one of them can be stored in the official runtime metadata because of the single runtimePath field.
@jmcphers (or anyone): any thoughts on the least disruptive way to accommodate a second path in the runtime metadata for R's sake? Possibilities:
- Introduce a second path-y field in
ILanguageRuntimeMetadata. If Python has no equivalent, it could be left undefined? - Generalize
runtimePathto an object or array instead of a single string, so each language has more flexibility to store whatever it needs.
Activity
jmcphers commentedon Jan 5, 2024
In my view, the runtime metadata structure should really only contain the fields that are relevant to Positron (and displayed in the UI). If we need additional context/data in a language pack, it's up to the language pack to work it out.
In this case, I think it'd be very straightforward to hang on to the
RInstallationobject and use it as a constructor argument when constructing anRRuntime. Then all interactions with the runtime will have access to all of the discovered info about the R installation.i.e. we construct the
RRuntimehere, which is during a loop overRInstallation:https://github.com/posit-dev/positron/blob/0c8a8b66597fd29aa1d71de726659e1c9dbc897e/extensions/positron-r/src/provider.ts#L241C34-L241C34
Would that do what you want?
jennybc commentedon Jan 5, 2024
OK yes this helps. We will work this out for ourselves in
RRuntimethen.jmcphers commentedon Jan 5, 2024
Oh, now that I read through all the connected issues I see that this issue is probably less about "give me the home/bin path for the version of R I am using" and more about "create a full RInstallation metadata from a Positron Runtime Metadata object".
I think the best way to approach that might be to use something other than (or in addition to) the Positron Runtime Metadata to remember/replay the active runtime. It could really just be an opaque token or object + the extension ID. Positron can put the token in storage and hand it back to the extension to start the runtime.
jennybc commentedon Feb 23, 2024
This remains an issue for the R extension but I also think it should wait until @jmcphers current work on refactoring runtimes is done. I'm associating it with the "Future" milestone because it's not user-facing. The timing of the work will be determined by when the next obvious person is working in the "neighborhood".
jmcphers commentedon Feb 23, 2024
I'm going to handle this work as part of the refactor, as an
extraDatafield extensions can use to supply their own extra fields to be recorded/played back with the metadata supplied to Positron.positron/extensions/positron-r/src/provider.ts
Lines 175 to 197 in 4ac76a9
jmcphers commentedon Mar 8, 2024
This is now implemented as part of #2415.
jmcphers commentedon Mar 12, 2024
Ready to verify. There isn't any user-facing behavior change, but could be verified by setting a breakpoint here:
positron/extensions/positron-r/src/runtime-manager.ts
Lines 25 to 28 in 2f20e42
and verifying that Positron is indeed retaining and passing
R_HOMEback to the R extension.jennybc commentedon Mar 13, 2024
Yes I can confirm that the homepath is available in the
R_HOMEenv var in thekernelSpec'senv. I'm not entirely clear how using it is going to play out exactly, but I'm sure that will work itself out.