How to Load Any Package in R (Unable to Load Shared Object)

Unable to load any package in R (unable to load shared object)

As BondedDust has explained in the comments, the problem has to do with the permissions that are given to users. I am connected to a network where the libraries are saved on a shared space. The issue was resolved by moving the default library to a local path.
The process that needs to be followed to change the library to a local one is quite simple and it is mentioned in the second answer in this question on stackoverflow.

Unable to load shared object on startup in RStudio only

I found the answer on RStudio Community: I had a typo in one of the variables used in Sys.getenv("PATH")

https://community.rstudio.com/t/unable-to-load-shared-object-on-startup-in-rstudio-only/33107

unable to load shared object 'TMB.so'

Improper Channel Mixing

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.

Recommendation: Conda Forge only

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

Demonstration

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.

Building R package on win32: Unable to load shared object (.dll)

The problem seems to have been the existence of 64-bit dlls in the package's source folder (as insinuated by the error message), created by 'devtools'.

Once these files were deleted load_all would happily re-create them using the 32-bit compilers.

package or namespace load failed error in loading R package litteR

You need to install the commando line tools. Open the Terminal.app and run the following line xcode-select --install



Related Topics



Leave a reply



Submit