rocker-org / rocker

R configurations for Docker
https://rocker-project.org
GNU General Public License v2.0
1.46k stars 271 forks source link

r: error while loading shared libraries: libR.so: cannot open shared object file: No such file or directory #538

Open ChillyMomo709 opened 9 months ago

ChillyMomo709 commented 9 months ago

Hi all,

I got an issue with installing packages in rocker/rstudio:4.3.1

install2.r --deps NA --error --skipinstalled --ncpus -1 BiocManager rstudioapi remotes languageserver aws.s3 usethis
r: error while loading shared libraries: libR.so: cannot open shared object file: No such file or directory
ERROR: process "/bin/sh -c /install_scripts/setup_r.sh" did not complete successfully: exit code: 127

Dockerfile

FROM rocker/rstudio:4.3.1

ENV \
    # R repositories and versions \
    CRAN_REPO="https://packagemanager.posit.co/cran/__linux__/jammy/2024-02-01/" \
    BIOC_REPO="https://ftp.gwdg.de/pub/misc/bioconductor/" \
    BIOC_VERSION="3.18" \

COPY ./install_scripts/setup_r.sh /install_scripts/setup_r.sh
RUN /install_scripts/setup_r.sh

install_scripts/setup_r.sh

#!/bin/bash
# setup R and install Bioconductor

set -e # exit script on error (non-zero exit status)
set -x # print command trace
set -u # exit when undeclared variables are used

# build ARGs
NCPUS=${NCPUS:--1}

# set the RStudio Package Manager repositories for CRAN (overrides CRAN set
# by rocker) and bioconductor and increase download timeout
echo "options(repos = c(CRAN = '${CRAN_REPO}'), BioC_mirror = '${BIOC_REPO}',
      download.file.method = 'libcurl', timeout = 600)" >> \
          ${R_HOME}/etc/Rprofile.site

# update all base R packages
/usr/local/lib/R/site-library/littler/examples/update.r --ncpus ${NCPUS:--1}

# setup bioconductor
install2.r --deps "NA" --error --skipinstalled --ncpus ${NCPUS:--1} \
    BiocManager \
    rstudioapi \
    remotes \
    languageserver \
    aws.s3 \
    usethis
YStrauchP4 commented 2 days ago

Hi! I stumbled upon the same issue. Judging from https://forum.posit.co/t/error-while-loading-shared-libraries-libr-so/101389/2, it appears the pre-compiled package provided by posit's CRAN didn't have the --enable-R-shlib flag set during compilation.

A quick workaround is to install from source, which works for me. I'm using specifically

install.packages('littler', repos='https://cran.r-project.org')

but I'm sure there are other, better ways to solve this problem