Using RStudio within a conda environment

Hello everyone,

I am very new to R and RStudio, and I am struggling to set up a conda environment with a specific R version, that I could then use with RStudio.

At first, I followed Anaconda guidelines (see Using R language with Anaconda — Anaconda documentation) by doing:

conda create -n r-environment r-essentials r-base
conda activate r-environment

However, the R installed version is then 3.6, whereas I would like to install R>=4.* because some of the libraries I will then use require a recent version of R.

Thus, I used coda-forge channel to install R within my conda environment:

conda create -n R-env
conda activate R-env
condac  install -c conda-forge r-base=4.1.2 r-essentials

The installation goes smoothly, I can open a R terminal and install libraries.

Yet, once in my env I cannot launch RStudio (/usr/bin/rstudio), I got the following error:

R Session Startup Failure Report

RStudio Version

RStudio 2021.09.2+382, "Ghost Orchid" (fc9e2179, 2022-01-04) for CentOS 7

Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) QtWebEngine/5.12.8 Chrome/69.0.3497.128 Safari/537.36

Error message

[No error available]

Process Output

The R session exited with code 1.

Error output:

/usr/lib/rstudio/bin/rsession: /lib64/libstdc++.so.6: version `CXXABI_1.3.8' not found (required by /data/users/pklein/Conda/miniconda3/envs/R-env/lib/R/lib/../../libicuuc.so.69)
/usr/lib/rstudio/bin/rsession: /lib64/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by /data/users/pklein/Conda/miniconda3/envs/R-env/lib/R/lib/../../libicuuc.so.69)
/usr/lib/rstudio/bin/rsession: /lib64/libstdc++.so.6: version `CXXABI_1.3.8' not found (required by /data/users/pklein/Conda/miniconda3/envs/R-env/lib/R/lib/../../libicui18n.so.69)
/usr/lib/rstudio/bin/rsession: /lib64/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by /data/users/pklein/Conda/miniconda3/envs/R-env/lib/R/lib/../../libicui18n.so.69)

Standard output:

[No output emitted]

Logs

/data/users/pklein/.local/share/rstudio/log/rsession-pklein.log

2022-02-07T09:05:44.257172Z [rsession-pklein] ERROR CLIENT EXCEPTION (rsession-pklein): (Error) : This API only accepts integers;|||http://127.0.0.1:24504/rstudio/AC5AADB35BD3AFF301FEFC583AAFE0E0.cache.js#-1::_verifyIntegers|||elemental2/dom/CSSProperties.java#1229::resize|||http://127.0.0.1:24504/rstudio/4032CB57FF3A58D9FCAE4CBA2130587E.cache.js#-1::fit|||org/rstudio/studio/client/workbench/views/terminal/xterm/XTermWidget.java#190::run|||com/google/gwt/user/client/Timer.java#124::fire|||rstudio-0.js#-1::eval|||com/google/gwt/core/client/impl/Impl.java#306::apply|||com/google/gwt/core/client/impl/Impl.java#345::entry0|||rstudio-0.js#-1::eval|||Client-ID: 33e600bb-c1b1-46bf-b562-ab5cba070b0e|||User-Agent: Mozilla/5.0 (X11  Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) QtWebEngine/5.12.8 Chrome/69.0.3497.128 Safari/537.36
2022-02-07T12:56:56.153451Z [rsession-pklein] ERROR Parent terminated; LOGGED FROM: void {anonymous}::detectParentTermination() src/cpp/session/SessionMain.cpp:1431
2022-02-07T12:56:56.153451Z [rsession-pklein] ERROR Parent terminated; LOGGED FROM: void {anonymous}::detectParentTermination() src/cpp/session/SessionMain.cpp:1431

As suggested here (c++ - version `CXXABI_1.3.8' not found (required by ...) - Stack Overflow) I installed gcc>=9 with conda and updated my LD_LIBRARY_PATH env variable.

Do you have any suggestions ?
Thank you very much for your time !
Best,
Paul

PS: I also tried to install RStudio within my conda env but I read many messages saying that it was not maintained and quite buggy (RStudio crash on open (downloaded with Anaconda) - #3 by Jmf369 Rstudio asking to save something on startup, failing to launch)

1 Like

As far as I know RStudio doesn't officially support running the R interpreter (or R core in Anaconda terms) trough a conda environment.

If you are committed to use conda environments for R, maybe because you are going to heavily use python in your project, I would recommend not using RStudio as your IDE because the integration is not seamless, consider using something more python focused like JupyterLab. Otherwise, consider using a regular R environment maybe with renv for package version management. If your concern is the Python package management side of things, have in mind that using conda envs for Python packages from R (and RStudio) it is well supported.

2 Likes

Hello @andresrcs thank you very much for your reply !
Ok I'll give a try with Jupyterlab then.

Best,
Paul

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.