Package Installation Issues

Problems with *.so libraries

If you see an error like this:

Error: package or namespace load failed for ‘sf’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/pfs/R/libs/4.2.0/sf/libs/sf.so':
  libproj.so.15: cannot open shared object file: No such file or directory

Most likely it means that a package was installed from a binary. Try reinstalling it from source:

install.packages("sf", repos = "https://cran.rstudio.com/")

Cannot open the connection

If you see something like this:

* Project '~/eucalyptus/packages/g6tr.projects/vignettes/2022-06-01_eucalyptus' loaded. [renv 0.15.4]
renv was unable to snapshot the following packages:

	'brew': cannot open the connection, 'cli': cannot open the
	connection, 'clipr': cannot open the connection,
	'commonmark': cannot open the connection, 'crayon': cannot
	open the connection,

… or any other similar message when you interact with renv, most likely it means messed up permissions inside the /pfs/R/renv folder. More specifically, some renv cache folders are not owned by the rstudio-users group, or this group does not have write permissions. To fix it, run the following as root:

sudo chown -R root:rstudio-users /pfs/R/renv
sudo chmod -R 2775 /pfs/R/renv

cmdstanr

cmdstanr R package needs cmdstan system library to work. This library is quite big, ~1Gb, and it’s not installed automatically with the package. Instead, the package comes with an installation helper: cmdstanr::install_cmdstan(). Any user can run it to install cmdstan into their home directory, but we are not going to let it this way for obvious reasons. What we are going to do is install it into a folder on the shared volume and make cmdstanr look into this folder by default.

For the first part, we need to connect through ssh and launch R as admin: sudo R. Shared R library needs to be set to .libPaths: .libPaths("/pfs/R/libs/4.2.0"). If cmdstanr is not installed, install it. And then install cmdstan system library to a folder on the shared drive: cmdstanr::install_cmdstan("/pfs/lib/cmdstan").

And the final touch - set this folder as the default path. For this we need to set an environment variable for all users. Add the following line to /etc/rstudio/rsession-profile:

# /etc/rstudio/rsession-profile
export CMDSTAN=/pfs/lib/cmdstan

Other individual cases

  • Bioconductor packages renv installation, e.g. Biobase: renv::install("Bioc::Biobase")

  • rethinking package: renv::install("rmcelreath/rethinking") (installation from Github)