Activate conda environments prior to creating R kernel sessions #10788
Conversation
When R is installed in a conda/mamba environment, the conda environment must be activated to ensure compilation tools and dependencies are available in PATH. This change implements full conda environment activation when starting R sessions from conda-based installations. Key changes: - Added condaEnvironmentPath field to RMetadataExtra and RInstallation - Created conda-activation module to activate conda/mamba environments and capture environment variables - Updated kernel spec creation to merge conda environment variables - Added experimental positron.r.interpreters.condaDiscovery setting to UI - Supports both conda and mamba, with platform-specific activation The conda discovery setting is opt-in (default: false) and clearly marked as experimental in the settings UI. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
|
E2E Tests 🚀 |
|
@wesm did you run |
Co-authored-by: Julia Silge <julia.silge@gmail.com> Signed-off-by: Jonathan <jonathan@posit.co>
juliasilge
left a comment
There was a problem hiding this comment.
So what I reported in #10788 (comment) was totally a "me" problem; I had cleaned out all the conda activation business out of my dot files at some point. 🙈
Once I did conda init, I could in fact start up my conda R environment and run code, make plots, etc:
I was not able to use install.packages() for a package that contains compiled code, which is the problem reported in #10359. This change does not set things up such that you can use install.packages().
I also want to highlight that it doesn't feel super solid in my experimentation. I experienced several crashes of R along with the R LSP. I do think we should merge this to see how intermittent such problems are (and they may not be related directly) but I wanted to note what I was seeing!
| "r.configuration.interpreters.exclude.markdownDescription": "List of absolute paths to R binaries or folders containing R installations to exclude from the available R interpreters. These interpreters will not be displayed in the Positron UI.\n\nIf an interpreter is both included via `#positron.r.customRootFolders#` or `#positron.r.customBinaries#` and excluded via `#positron.r.interpreters.exclude#`, it will not be displayed in the Positron UI. See also `#positron.r.interpreters.override#`.\n\nExample: On Linux, add `/custom/location/R/4.3.0/bin/R` to exclude the specific binary, or `/custom/location` to exclude any R installations within the directory.\n\nRequires a restart to take effect.", | ||
| "r.configuration.interpreters.override.markdownDescription": "List of absolute paths to R binaries or folders containing R installations to override the list of available R interpreters. Only the interpreters found at the specified paths will be displayed in the Positron UI.\n\nThis setting takes precedence over the `#positron.r.customBinaries#`, `#positron.r.customRootFolders#`, and `#positron.r.interpreters.exclude#` settings.\n\nExample: On Linux or Mac, add `/custom/location/R/4.3.0/bin/R` to include only this specific installation, or `/custom/location` to include only R installations found within the directory.\n\nRequires a restart to take effect.", | ||
| "r.configuration.interpreters.default.markdownDescription": "Absolute path to the default R binary to use for new workspaces. This setting no longer applies once you select an R interpreter for the workspace.\n\nExample: On Linux, add `/custom/location/R/4.3.0/bin/R` to set the default interpreter to the specific R binary.\n\nRequires a restart to take effect.", | ||
| "r.configuration.interpreters.condaDiscovery.markdownDescription": "Enable discovery of R installations within conda/mamba environments. Support for conda environments in Positron is experimental and may not work correctly in all cases. When enabled, R installations found in conda environments will be available for selection, and the conda environment will be automatically activated when starting R to ensure compilation tools and dependencies are available.\n\nRequires a restart to take effect.", |
There was a problem hiding this comment.
Should we make a claim about compilation tools? I still can't use install.packages() with this change and have to install packages via conda.
Also, I do think the suggestion from @jennybc to get more explicit here about "starting the R console" is probably a good idea.
…dows' into feature/conda-activate-for-r


This change:
Conda: env_namein the picker.conda activateinside the shell that runs Conda R kernels, using a new kernel supervisor feature. This feature is also intended to support other preflight commands in the future. e.g.module load(Support interpreter environments defined by Environment Modules #8075).The bulk of this change lives in the kernel supervisor: posit-dev/kallichore#55
Supersedes #10471.
Release Notes
conda activate. Note that not all of Positron's R features have been tested with Conda R. (Support R interpreters installed via conda #4398)New Features
Bug Fixes
QA Notes
This change brings in a new supervisor version that has more sophisticated startup handling to support the new features, so it is worth checking that old settings like "Run in Shell" continue to work.