Reputation: 101
In one of my conda environments in terminal, I am able to successfully install the package 'rjags'. However, when I run R within that environment and run library(rjags), I get the following error:
Loading required package: coda Error: package or namespace load failed for 'rjags': .onLoad failed in loadNamespace() for 'rjags', details: call: dyn.load(file, DLLpath = DLLpath, ...) error: unable to load shared object '/user-path/anaconda3/envs/r-env/lib/R/library/rjags/libs/rjags.so': /user-path/anaconda3/envs/r-env/lib/R/library/rjags/libs/rjags.so: undefined symbol: _ZN4jags7Console10setRNGnameERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEj In addition: Warning messages: 1: package 'rjags' was built under R version 3.6.3 2: package 'coda' was built under R version 3.6.3
If I install and with R, perform library(rjags) in another environment or in the base environment, everything works fine. I am wondering what this error message means and how to resolve it.
The output of conda list "^(libstdcxx-ng|r-base|r-coda|jags|r-rjags)$"
is:
# packages in environment at /user-path/anaconda3/envs/r-env:
#
# Name Version Build Channel
jags 4.3.0 h26a2512_0 conda-forge
libstdcxx-ng 9.1.0 hdf63c60_0
r-base 3.6.1 h9bb98a2_1
r-coda 0.19_3 r36h6115d3f_2 conda-forge
r-rjags 4_10 r36h0357c0b_1 conda-forge
Upvotes: 4
Views: 3163
Reputation: 76960
I suspect that the error is due to mixing of Conda Forge and Anaconda packages. The organizations use different build stacks and so the dynamic libraries they build can end up having different internal definitions (for details, see this Issue on the Conda Forge repository). For example, in this case rjags.so
is built to look for a symbol in the libraries that it links to, but it fails to find it in the Anaconda builds. Unfortunately, it links to too many (check with ldd rjags.so
) for me to track down which specifically is causing the issue.
However, you still have a some options to get rjags
working, just not a precision fix. In all cases the solution is to prioritize the conda-forge channel.
If you don't actually need rjags
in this specific env, then create a new one with the packages you will need. However, when doing so, make conda-forge the priority channel over defaults:
conda create -n rjags_env -c conda-forge r-rjags
conda activate rjags_env
conda config --env --add channels conda-forge
If your goal is to add rjags
to the existing env, and you can't figure out the specific package that needs to change, you instead could recreate the env with the updated priority.
First, export the env to a YAML like
conda env export -n r-env --no-builds > rjags_env.yaml
Next, edit this file so that the channels section reads:
name: rjags_env
channels:
- conda-forge
- defaults
dependencies:
Finally create a new version of the env with
conda env create -f rjags_env.yaml -n rjags_env
I also looked into using the --update-deps
flag with conda install
, but that forces the env to update to R v4.0.1 and breaks the r-coda
install.
Upvotes: 3