You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm working in a different conda environment for each of my projects and would like to have R launch within the correct environment when I cmd-enter on a line of R code (I'm using Mac OS X) so that I can use the R version and packages I have in my environment. I have figured out that if I install Microsoft's Python Extension and put ...
in {workspace-directory}/.vscode/settings.json then when I start a new bash terminal, the first command it will run is conda activate env-01. Unfortunately, when I do this with R code (e.g. 2+2) in a file (e.g. practice.R), it launches a new terminal and the first R command it tries to run is conda activate env-01 followed by 2+2.
Here's what the output to the terminal looks like:
conda activate env-01
2+2
R version 4.2.1 (2022-06-23) -- "Funny-Looking Kid"
Copyright (C) 2022 The R Foundation for Statistical Computing
Platform: aarch64-apple-darwin20 (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
Natural language support but running in an English locale
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> conda activate env-01
Error: unexpected symbol in "conda activate"
> 2+2
[1] 4
I'm not really excited about adding "r.alwaysUseActiveTerminal": true to my settings.json file (as suggested here) since I like the flexibility of being able to "just" create the R terminal by doing cmd-enter.
It seems like there should be a way to automatically run the conda activate <environment_name> before launching R for the first time when doing cmd-enter on a chunk of R code. Is there a setting I'm missing or would this be something that could easily be fixed?
The text was updated successfully, but these errors were encountered:
I'm working in a different conda environment for each of my projects and would like to have R launch within the correct environment when I
cmd-enter
on a line of R code (I'm using Mac OS X) so that I can use the R version and packages I have in my environment. I have figured out that if I install Microsoft's Python Extension and put ...in
{workspace-directory}/.vscode/settings.json
then when I start a new bash terminal, the first command it will run isconda activate env-01
. Unfortunately, when I do this with R code (e.g.2+2
) in a file (e.g.practice.R
), it launches a new terminal and the first R command it tries to run isconda activate env-01
followed by2+2
.Here's what the output to the terminal looks like:
I'm not really excited about adding
"r.alwaysUseActiveTerminal": true
to mysettings.json
file (as suggested here) since I like the flexibility of being able to "just" create the R terminal by doingcmd-enter
.It seems like there should be a way to automatically run the
conda activate <environment_name>
before launching R for the first time when doingcmd-enter
on a chunk of R code. Is there a setting I'm missing or would this be something that could easily be fixed?The text was updated successfully, but these errors were encountered: