rconda

Conda environment loading a different R version than what I installed


I am trying to use the most recent version of R available in conda-forge. My yml file looks like this:


    name: gigante
    channels:
     - conda-forge
    dependencies:
      - gdal
      - r

When I create the environment, I then verify the version of R is what I wanted, which it is (4.4.2). Yet when I then want to start coding in R within the environment, it says 4.3.1. I've even tried just installing r-base in the yml file but I get the same result. I have no idea what's going on.

Is this because of conflicted versions of packages within r-essentials and r-recommended? Is something messed up with my anaconda installation overall?

Here's the r output for conda-list:

r                         4.4             r44hd8ed1ab_1008    conda-forge
r-base                    4.4.2                h1f3f453_2    conda-forge
r-boot                    1.3_31            r44hc72bb7e_0    conda-forge
r-class                   7.3_23            r44h79f565e_0    conda-forge
r-cluster                 2.1.8             r44hb3c2f18_0    conda-forge
r-codetools               0.2_20            r44hc72bb7e_1    conda-forge
r-foreign                 0.8_88            r44h79f565e_0    conda-forge
r-kernsmooth              2.23_26           r44hd6847f7_0    conda-forge
r-lattice                 0.22_6            r44h6b9d099_1    conda-forge
r-mass                    7.3_64            r44h79f565e_0    conda-forge
r-matrix                  1.6_5             r44h9cf22e7_1    conda-forge
r-mgcv                    1.9_1             r44h374a70c_1    conda-forge
r-nlme                    3.1_165           r44h9612530_1    conda-forge
r-nnet                    7.3_20            r44h79f565e_0    conda-forge
r-recommended             4.4             r44hd8ed1ab_1007    conda-forge
r-rpart                   4.1.24            r44h79f565e_0    conda-forge
r-spatial                 7.3_18            r44h79f565e_0    conda-forge
r-survival                3.8_3             r44h79f565e_0    conda-forge

And here's the output for trying to start R:

(base) username@Mac driveLocation % conda activate gigante
(gigante) username@Mac driveLocation % R

R version 4.3.1 (2023-06-16) -- "Beagle Scouts"
Copyright (C) 2023 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.

Edited to show that the base conda env is activated by default.


Solution

  • Looks like the answer is simpler than I thought and directly related to Conda using /usr/local/bin/python instead of conda environment python. My VSCode is set up whereby conda activate base is automatically run. If I deactivate that prior to activating my focal environment (gigante), then there's no issue and the correct version of R loads.