0

How can I find out which shared library R has found? My present situation is as follows:

We are attempting to provide an R environment with several different interfaces, while providing as much consistency as possible (e.g., we would like to have the same libraries available in all interfaces): we can invoke R from a console, we can run RStudio, and we can run R notebooks under Jupyter notebooks. All three interfaces are supported by the same Unix-alike hardware and operating system (RedHat). Different users have different interface preferences.

Under our current configuration, we can run R from the console and load the vroom package just fine:

$ R
> library(vroom)
> # no news is good news

However, under current conditions, library(vroom) fails under our RStudio setup:

> library(vroom)
Error: package or namespace load failed for ‘vroom’ in dyn.load(file, DLLpath = DLLpath, ...):
  unable to load shared object '/PATH-PREFIX-REDACTED/miniconda3-1/envs/r/lib/R/library/vroom/libs/vroom.so':
  miniconda3-1/envs/r/lib/R/lib/libstdc++.so.6: version `GLIBCXX_3.4.30' not found (required by /PATH-PREFIX-REDACTED/miniconda3-1/envs/r/lib/R/library/vroom/libs/vroom.so)

The error from RStudio gives me a clue about why it is failing. But how can I find out why the console version is succeeding (which libstdc++.so.6 did it find)?

I have read a little (on StackOverflow [1, 2] and elsewhere [3]) about how dyn.load might be working, but I still do not understand why the consolde R successfully loads vroom when none of the libstdc++.so.6 on LD_LIBRARY_PATH have GLIBCXX_3.4.30 (according to my understanding of the output of objdump -x).

Additional Information

The .libPaths() is the same in both "console" and "RStudio" R:

> .libPaths()
# [1] "PATH-PREFIX-REDACTED/R_LIBS_SITE/R4.2"                 
# [2] "PATH-PREFIX-REDACTED/miniconda3-1/envs/r/lib/R/library"

AFAICT (ls <directory>), the vroom package is installed under only the "miniconda" path of .libPaths(), so I am afraid @Mikael-Jagan's point is sorta moot (however, +1 for pointing out the new-to-me tool of ldd): apparently the same vroom.so is being loaded under "console" and "RStudio" R. And now I am more confused, because shouldn't the vroom package then be finding the same libstdc++.so.6 in either case?

$ # PATHNAMES, USER NAMES, AND GROUP NAMES HAVE BEEN CHANGED
$ # TO PROTECT THE INNOCENT.
$ # REFORMATTED FOR LEGIBILITY ON A WINDOW OF USUAL SIZE.
$ pwd
/PATH-PREFIX-REDACTED/miniconda3-1/envs/r/lib/R/library/vroom/libs/
$ ldd vroom.so | grep 'libstdc*'
libstdc++.so.6 => /PATH-PREFIX-REDACTED/miniconda3- 
        1/envs/r/lib/R/library/vroom/libs/../../../../libstdc++.so.6 
        (0x00002b2277b8a000)
$ cd /beohome/a/ScientificProgramSupport/local/miniconda3- 
        1/envs/r/lib/R/library/vroom/libs/../../../..
$ ls -lF libstdc*
lrwxrwxrwx 1 admin admin       19 Oct 25 15:51 libstdc++.so -> 
        libstdc++.so.6.0.30*
lrwxrwxrwx 1 admin admin       19 Oct 25 15:51 libstdc++.so.6 -> 
        libstdc++.so.6.0.30*
lrwxrwxrwx 1 admin admin       19 Oct 28 12:38 libstdc++.so.6.0.21 -> 
        libstdc++.so.6.0.24
-rwxrwxr-x 3 admin admin 12212840 Oct 23 06:08 libstdc++.so.6.0.30*
$ objdump -x libstdc++.so.6 | grep ' GLIBCXX_3\.4\.30'
32 0x00 0x0297f840 GLIBCXX_3.4.30
0000000000000000 g     O *ABS*  0000000000000000
        GLIBCXX_3.4.30

And now I am even more confused, because it looks to like ldd and objdump together are telling me that GLIBCXX_3.4.30 is part of the libstdc++.so.6 that vroom.so should find.

Ana Nimbus
  • 635
  • 3
  • 16
  • How are you installing these packages? Are these all running on the exact same machine? It sounds like you may be installing from source which may compile differently on different machines. – MrFlick Feb 21 '23 at 21:07
  • What is the output of `.libPaths()` in each environment? You may have **vroom** installed in two places and built differently in each place, in which case you can do `otool -L /path/to/vroom.so` to learn where each library is finding symbols. – Mikael Jagan Feb 21 '23 at 21:40
  • Added info on `.libPaths()` per prompting of @MikaelJagan. – Ana Nimbus Feb 21 '23 at 21:53
  • @MikaelJagan I don't think we have `otool`: `man otool`, `info otool`, and `type otool` indicate as much. – Ana Nimbus Feb 21 '23 at 21:59
  • So you are using miniconda? Is that how you installed the packages? Are you using conda environments? The conda didistributions of R aren't the official distributions so things don't always seem to work correctly with this. – MrFlick Feb 21 '23 at 22:04
  • 1
    Oops - that was a typo, because I've been using macOS lately. I meant `ldd /path/to/vroom.so`, but my suggestion might be moot if the same shared object is loaded in both environments. – Mikael Jagan Feb 21 '23 at 22:07
  • @MrFlick RE miniconda, etc.: Yes, using miniconda for most of our R stufff (a few packages are not available via miniconda and are installed in other ways, e.g., `install.packages`). Pretty sure we used conda to install vroom---there is a vrrom subdirectory under `.../miniconda3-1/envs/r/lib/R/library`. Yes, using conda environments (one called "r", in this case). – Ana Nimbus Feb 22 '23 at 20:16
  • I have provided additional information in the post, but I want to stay focussed on the actual question, which is still important to me: **Which shared library is R finding?** (some `libstdc++.so.6` in this case, but which one?) – Ana Nimbus Feb 22 '23 at 21:32

0 Answers0