Rstudio (in contrast to R in console) reports Error in dyn.load (unable to load shared object)

I am having troubles with the Rstudio IDE and some packages, in particular right now: readxl.
I use conda environments with the prefix option (conda create -p /home/user/myproject/envs/default) to install all packages.
Therefore, if my conda environment is not active there is no system wide installation of R.
I activate the environment and install base R via 'conda install -c conda-forge r-base'. This retrieves R version 4.2.1 with the following error:

SafetyError: The package for r-base located at /home/user/miniconda3/pkgs/r-base-4.2.1-ha8c3e7c_1
appears to be corrupted. The path 'lib/R/doc/html/packages.html'
has an incorrect size.
reported size: 3423 bytes
actual size: 7734 bytes

but R still works fine.
Afterwards I install readxl via 'conda install -c r r-readxl'.
On the command line the program works just fine while in Rstudio i get the error message

Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/home/user/myproject/envs/default/lib/R/library/readxl/libs/readxl.so':
/usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.26' not found (required by /home/user/myproject/envs/default/lib/R/library/readxl/libs/readxl.so)

My library path in R (.libPaths()) is

/home/user/myproject/envs/default/lib/R/library

and while /usr/lib/x86_64-linux-gnu/libstdc++.so.6 only has GLIBCXX_3.4.25

strings /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | grep GLIBCXX_3.4.2

GLIBCXX_3.4.2
GLIBCXX_3.4.20
GLIBCXX_3.4.21
GLIBCXX_3.4.22
GLIBCXX_3.4.23
GLIBCXX_3.4.24
GLIBCXX_3.4.25

the default lib specified by readxl.so

ldd envs/default/lib/R/library/readxl/libs/readxl.so

libstdc++.so.6 => /home/user/myproject/envs/default/lib/R/library/readxl/libs/../../../../libstdc++.so.6 (0x00007f063bb82000)

has more versions of GLIBCXX including the requested 3.4.26).

strings /home/user/myproject/envs/default/lib/R/library/readxl/libs/../../../../libstdc++.so.6 | grep GLIBCXX_3.4.2

GLIBCXX_3.4.2
GLIBCXX_3.4.20
GLIBCXX_3.4.21
GLIBCXX_3.4.22
GLIBCXX_3.4.23
GLIBCXX_3.4.24
GLIBCXX_3.4.25
GLIBCXX_3.4.26
GLIBCXX_3.4.27
GLIBCXX_3.4.28
GLIBCXX_3.4.29
GLIBCXX_3.4.21
GLIBCXX_3.4.28
GLIBCXX_3.4.25
GLIBCXX_3.4.24
GLIBCXX_3.4.20
GLIBCXX_3.4.2
GLIBCXX_3.4.27
GLIBCXX_3.4.23
GLIBCXX_3.4.29
GLIBCXX_3.4.22
GLIBCXX_3.4.26

This happens not only for r-base=4.2.1 (I checked some others, all > 4) and r-readxl=1.4.0 (e.g. also for stringr).
I've reached the end of the line here and hope somebody can point me to a solution.

Best,

Oliver

As far as I know, Rstudio IDE (the open source version of the IDE) doesn't officially support conda environments for the R setup (only for python). But I think a better place to report this, in case this is something they offer support for, is the GitHub repository.

I found a solution for my problem here:

shared library - version `GLIBCXX_3.4.26' not found even though libstdc++.so.6 recent enough - Ask Ubuntu

Turns out that rstudio sets the environment variable 'LD_LIBRARY_PATH' which pointed to /usr/lib/x86_64-linux-gnu. When I used
export LD_LIBRARY_PATH=/home/user/myproject/envs/default/lib
before calling 'rstudio' the error disappears.

Apparently that was only the solution for last week. Now when I use
conda activate envs/default
export LD_LIBRARY_PATH=/home/user/myproject/envs/default/lib
rstudio
I get an error on rstudio startup

TTY detected. Printing informational message about logging configuration. Logging configuration loaded from '/etc/xdg/xdg-ubuntu:/etc/xdg/rstudio/logging.conf'. Logging to '/home/user/.local/share/rstudio/log/rdesktop.log'.
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, xcb.
/usr/lib/rstudio/bin/crashpad_handler: envs/default/lib/libcurl.so.4: no version information available (required by /usr/lib/rstudio/bin/crashpad_handler)
[7715:7716:20220817,094025.414765:ERROR directory_reader_posix.cc:42] opendir: No such file or directory (2)
[7715:7715:20220817,094025.415886:ERROR process_memory_range.cc:86] read out of range
[7715:7715:20220817,094025.415897:ERROR elf_image_reader.cc:558] missing nul-terminator
[7715:7715:20220817,094025.416075:ERROR process_reader_linux.cc:445] no module mappings 0x7faab536a000
Aborted (core dumped)

This topic was automatically closed 21 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.