I installed broom.mixed package via conda conda install -c conda-forge r-broom.mixed
, however, it doesn't import and shows error message:
library(broom.mixed)
Error: package or namespace load failed for ‘broom.mixed’:
.onLoad failed in loadNamespace() for 'TMB', details:
call: dyn.load(file, DLLpath = DLLpath, ...)
error: unable to load shared object '/local/home/hsinhung/anaconda3/envs/r-env/lib/R/library/TMB/libs/TMB.so':
libopenblas.so.0: cannot open shared object file: No such file or directory
2022/1/17 added "hopefully" reproducible examples:
I created a clean R environment in Anaconda via below commands:
conda create -n r_env_test r-essentials r-base
(following Anaconda R env instruction)
conda activate r_env_test
conda install -c conda-forge r-broom.mixed
(following Anaconda broom.mixed instruction)
then I enter R
console, and execute library(broom.mixed)
. The error pops up right away:
> library(broom.mixed)
Error: package or namespace load failed for ‘broom.mixed’:
.onLoad failed in loadNamespace() for 'TMB', details:
call: dyn.load(file, DLLpath = DLLpath, ...)
error: unable to load shared object '/local/home/hsinhung/anaconda3/envs/r_env_test/lib/R/library/TMB/libs/TMB.so':
libopenblas.so.0: cannot open shared object file: No such file or directory
In addition: Warning message:
package ‘broom.mixed’ was built under R version 3.6.3
As @merv suggested, here the output of package versions in the new test environment:
x86_64-conda_cos6-linux-gnu % conda list '(libblas|liblapack|r-base|r-tmb|r-broom.mixed)'
# packages in environment at /home/hsinhung/anaconda3/envs/r_env_test:
#
# Name Version Build Channel
r-base 3.6.1 haffb61f_2
r-base64enc 0.1_3 r36h96ca727_4
r-broom.mixed 0.2.6 r36h6115d3f_0 conda-forge
r-tmb 1.7.16 r36h0357c0b_0 conda-forge
(r_env_test)
(22-01-17 8:16:12) <0> [~]
x86_64-conda_cos6-linux-gnu %
Any suggestion how I can get this package going in Anaconda?
I believe the issue being encountered is primarily driven by mixing the defaults channel (specifically the r channel) and the conda-forge channel. This is known to lead to missing libraries and missing symbol references in shared libraries because Anaconda and Conda Forge use different build stacks and sometimes different recipes.
In this case, r-broom.mixed
depends on r-tmb
, which on Conda Forge depends on libblas
and liblapack
, but on the r channel does not have these dependencies.
Generally, I recommend that Conda users who want R environments should only use Conda Forge and avoid using the r channel. This is because the r channel has mostly been abandoned from what I can tell (e.g., no R version 4 releases, and most packages have not been updated for over a year).
Furthermore, I would discourage the use of the r-essentials
package. Analogous to the Anaconda distribution of Python (anaconda
package), the r-essentials
package bundles together many packages that are anticipated to be used by data scientists, but some of it simply seems bloated to me. Something specific that troubles me about it is that it ends up pulling in Python in addition to R. No one should need to have Python mixed in with an R environment. This is due to including notebook
, which if users really want to load an R environment as a kernel, they only need r-irkernel
(as demonstrated below).
In summary, one should be fine simply doing:
conda create -n foo -c conda-forge r-base r-broom.mixed
To verify that the BLAS implementation doesn't make a difference, I tested using MKL and OpenBLAS.
I encounter no issues with the following setup:
## dedicated jupyter environment
mamba create -n jupyter jupyter nb_conda_kernels
## broom.mixed with MKL backend
mamba create -n broom_mkl r-base=4.1 r-broom.mixed r-irkernel 'blas=*=*mkl*'
## broom.mixed with OpenBLAS backend
mamba create -n broom_openblas r-base=4.1 r-broom.mixed r-irkernel 'blas=*=*openblas*'
## launch jupyter
conda activate jupyter
jupyter notebook
With Jupyter launched I can create a new notebook with either the broom_mkl
or broom_openblas
kernels, and running library(broom.mixed)
loads without any error.
This is on osx-64 platform.