Overview
Package install#
The versions of R available through module load are bare ones, that is, they are provided without any extra packages. Here is how you can install them in your own environment. The easiest way to do so is to use R_install_packages helper script, available for all versions of R.
- choose the
Rversion you need, we recommend starting with the most recent one:
Code Block (bash)
maestro-submit:~ > module av R/
--------------------------- /opt/gensoft/devmodules ----------------------------
R/3.6.2 R/4.0.2 R/4.1.0 R/4.2.1 R/4.2.2 R/4.3.0 R/4.4.0
- first install prerequisite
devtoolsR library forR_install_packages.Example withR/4.4.0. adapt toRversion you need.
Code Block (bash)
maestro-submit:~ > module load R/4.4.0 gcc/9.2.0 libxml2 libiconv freetype fontconfig harfbuzz fribidi curl libwebp
maestro-submit:~ > R_install_packages devtools
[1] "installing packages: devtools to ~/R/x86_64-pc-linux-gnu-library/4.4"
also installing the dependencies 'Rcpp', 'utf8', 'askpass', 'credentials', 'openssl', 'sys', 'zip', 'gitcreds', 'ini', 'fastmap', 'httpuv', 'mime', 'xtable', 'fontawesome', 'sourcetools', 'later', 'promises', 'base64enc', 'sass', 'jquerylib', 'fansi', 'vctrs', 'systemfonts', 'textshaping', 'tinytex', 'xfun', 'pillar', 'pkgconfig', 'highr', 'diffobj', 'rematch2', 'clipr', 'crayon', 'curl', 'gert', 'gh', 'glue', 'jsonlite', 'purrr', 'rappdirs', 'rprojroot', 'rstudioapi', 'whisker', 'yaml', 'R6', 'cachem', 'shiny', 'htmltools', 'callr', 'prettyunits', 'bslib', 'digest', 'downlit', 'httr', 'magrittr', 'ragg', 'rmarkdown', 'tibble', 'xml2', 'htmlwidgets', 'stringr', 'xopen', 'brew', 'commonmark', 'knitr', 'cpp11', 'brio', 'evaluate', 'praise', 'processx', 'ps', 'waldo', 'usethis', 'cli', 'desc', 'ellipsis', 'fs', 'lifecycle', 'memoise', 'miniUI', 'pkgbuild', 'pkgdown', 'pkgload', 'profvis', 'rcmdcheck', 'remotes', 'rlang', 'roxygen2', 'rversions', 'sessioninfo', 'testthat', 'urlchecker', 'withr' [...]
[...]
* installing *source* package 'devtools' ...
** package 'devtools' successfully unpacked and MD5 sums checked
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
*** copying figures
** building package indices
** installing vignettes
** testing if installed package can be loaded
* DONE (devtools)
The downloaded source packages are in
'/local/scratch/RtmphFIn3B/downloaded_packages
please note that by default R libraries are installed to ~/R/x86_64-pc-linux-gnu-library/<R_VERSION> where R_VERSION corresponds to the first 2 digits of the R module version you loaded
3. Now you can use R_install_packages to download and install the packages you need. Note that if required packages are missing, you will have to install them first. For example, if you want to install a package from github that needs the devtools package that is not already installed in your environment, you will be stopped right away.
Once the required packages are installed, you can install your target packages:
Code Block (bash)
$ R_install_packages --git-hub bodkan/admixr
[1] "installing packages: bodkan/admixr to ~/R/x86_64-pc-linux-gnu-library/3.5"
Downloading GitHub repo bodkan/admixr@master
[...]
* installing *source* package 'admixr' ...
** R
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
* DONE (admixr)
Note that if you want to install a specific release, you have to add the version using @ . If you don't, as seen above, you fetch the files from the master branch
4.
Code Block (bash)
$ R_install_packages --git-hub bodkan/admixr@v0.9.1
[1] "installing packages: bodkan/admixr@v0.9.1 to /pasteur/appa/homes/<yourlogin>/R/x86_64-pc-linux-gnu-library/4.3"[1]
Downloading GitHub repo bodkan/admixr@v0.9.1
[...]
* installing *source* package 'admixr' ...
** using staged installation
** R
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (admixr)
Note that in the example above, the packages are installed in ~/R/x86_64-pc-linux-gnu-library/4.0. You can specify another place by using --libs option or by setting R_LIBS_USER environment variable. If the target package requires other packages such as in the example above, prefer the environment variable R_LIBS_USER to insure that the target package, here bodkan/admixr will know that is must look for the required package, here devtools, in the alternative path rather than in ~/R/x86_64-pc-linux-gnu-library/4.0. Example:
Code Block (bash)
$ R_LIBS_USER=/path/to/my/project/space/R/4.0; export R_LIBS_USER
$ R_install_packages devtools
[1] "installing packages: devtools to /path/to/my/project/space/R/4.0"
[...]
* installing *source* package 'devtools' ...
** package 'devtools' successfully unpacked and MD5 sums checked
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
*** copying figures
** building package indices
** installing vignettes
** testing if installed package can be loaded
* DONE (devtools)
$ R_install_packages --git-hub bodkan/admixr
[1] "installing packages: bodkan/admixr to /path/to/my/project/space/R/4.0"
Downloading GitHub repo bodkan/admixr@master
[...]
* installing *source* package 'admixr' ...
** R
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
* DONE (admixr)
Trouble shooting#
Missing command#
if your command fails with an error that look likes "XYZ command not found", or "Cannot find XYZX", eg:
Code Block (bash)
checking for curl-config... no
Cannot find curl-config
ERROR: configuration failed for package ‘RCurl’"
it means that a dependency is missing to fulfill the build. The wp utility available on maestro helps you to locate the required module to load.
Example:
Code Block (bash)
maestro-submit:~ > wp curl-config
curl-config is found in module(s): curl/7.68.0
So just load the module that provides the missing command/program and issue the install again.
Another common error you may encounter is
Code Block (bash)
make: gfortran: Command not found
It means some compilation tools are missing in your path. In this case you need to module load gcc.
NB on Maestro all R versions have been built using gcc/9.2.0 so we recommend that you use the same version to build the libraries that require it.
Missing header#
Sometimes you may encounter an error that looks like:
Code Block (bash)
In file included from caches.h:7,
from caches.cpp:1:
ft_cache.h:9:10: fatal error: ft2build.h: No such file or directory
9 | #include <ft2build.h>
| ^~~~~~~~~~~~
It means that some header files are missing from your environment, in this case you need to module load freetype
Missing library#
Some errors like the ones below indicates that a required library is not found,
Code Block (bash)
"user/bin/ld: cannot find -liconv
collect2: error: ld returned 1 exit status
Code Block (bash)
Configuration failed because libxml-2.0 was not found. Try installing:
Check modules list in order to see if one of the available modulefiles provides it. In case 1 module libiconv is the required one while case 2 needs libxml2 to be loaded.
NB sometimes finding required module given the error message may be tricky, google the error message will give you some insights on what to look for while doing a module av search
Example: common troubles with 'tidyverse', 'readxl' and 'haven' packages#
To insall tidyverse with R_install_packages without problem, the easiest way is to load the same modules as for the devtools above and then do the following export before invoking R_install_packages:
Code Block (text)
$ module load R/4.4.0 gcc/9.2.0 libxml2 libiconv freetype fontconfig harfbuzz fribidi curl
$ export LIB_DIR=" $LIBICONV_ROOT/lib -liconv "
$ export PKG_LIBS="-L $LIBICONV_ROOT/lib -liconv -lz"
$ export INCLUDE_DIR="./include/"
The explanations are below.
The package named tidyverse requires the readxl and haven package. Depending on what you already have in your shell environment you may encounter the following errors.
undefined symbol: libiconv#
If you encounter an error such as
Code Block (text)
Error: package or namespace load failed for 'readxl' in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/pasteur/appa/homes/<yourlogin>/R/x86_64-pc-linux-gnu-library/4.4/00LOCK-readxl/00new/readxl/libs/readxl.so':
/pasteur/appa/homes/<yourlogin>/R/x86_64-pc-linux-gnu-library/4.4/00LOCK-readxl/00new/readxl/libs/readxl.so: undefined symbol: libiconv
Error: loading failed
Execution halted
ERROR: loading failed
* removing '/pasteur/appa/homes/<yourlogin>/R/x86_64-pc-linux-gnu-library/4.4/readxl'
Warning: simpleWarning in install.packages(args, lib = user_lib, repos = repo): installation of package 'readxl' had non-zero exit status
then, you must provide a correct PKG_LIBS environment variable by doing the following
Code Block (text)
$ export PKG_LIBS="-L $LIBICONV_ROOT/lib -liconv -lz"
to allow readxl to find libiconv.
Code Block (text)
If you rather encounter
Code Block (text)
Error: package or namespace load failed for ‘haven’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/pasteur/appa/homes/<yourlogin>/R/x86_64-pc-linux-gnu-library/4.4/00LOCK-haven/00new/haven/libs/haven.so':
/pasteur/appa/homes/<yourlogin>/R/x86_64-pc-linux-gnu-library/4.4/00LOCK-haven/00new/haven/libs/haven.so: undefined symbol: libiconv
Error: loading failed
Execution halted
Warning: simpleWarning in install.packages(args, lib = user_lib, repos = repo): installation of package ‘haven’ had non-zero exit status
check at the top of the tidyverse installation output if you don't have something like the following at the top
Code Block (text)
[1] "installing packages: tidyverse to ~/R/x86_64-pc-linux-gnu-library/X.X"
Found INCLUDE_DIR and/or LIB_DIR!
and just after
Code Block (text)
Using PKG_LIBS=-L -lz
If yes, before relaunching R_install_packages , do
Code Block (text)
$ export LIB_DIR=" $LIBICONV_ROOT/lib -liconv "
to allow haven to find libiconv.Indeed, it reconstructs its own PKG_LIBS (even if you already have one such as the one for readxl) using LIB_DIR.
readstat.h: No such file or directory#
If you encounter the following error
Code Block (text)
DfReader.cpp:9:10: fatal error: readstat.h: No such file or directory
9 | #include "readstat.h"
| ^~~~~~~~~~~~
compilation terminated.
make: *** [/opt/gensoft/exe/R/4.1.0/lib64/R/etc/Makeconf:177: DfReader.o] Error 1
ERROR: compilation failed for package haven
and this time you have at the top something of the kind
Code Block (text)
Found INCLUDE_DIR and/or LIB_DIR!
Using PKG_CFLAGS=-I
then you must export a non-empty INCLUDE_DIR variable:
Code Block (text)
$ export INCLUDE_DIR="./include"
to avoid PKG_CFLAGS to only contain -I . That prevents haven from finding its own readstat.h file.
Then relaunchthe R_install_packages commandon tidyverse
R_install_packages overview#
R_install_packages comes with an online help available through the following command
Code Block (bash)
maestro-submit:~ > R_install_packages --help
Usage: R_install_packages [options] pkgs
Download and install packages from CRAN-like repositories, Bioconductor, git-hub or from local source archive to your $HOME/R library
Options:
--bioclite
Install package from bioclite bioconductor. (default: OFF)
--bioclite-update
Turns on bioclite automatic updating. (default: OFF)
--bioclite-autoupdate
Turns on bioclite BiocInstaller auto updating. (default: OFF)
--gitlab
Install package from gitlab (default: OFF)
repository address must be in format: 'username/repo[@ref]'
--gitlab-host=GITLAB-HOST
GitLab API host to use (default: gitlab.com)
--github
Install package from git-hub (default: OFF)
repository address must be in format: 'username/repo[/subdir][@ref|#pull]'
--github-ref=GITHUB-REF
git reference. Could be a commit, tag, or branch name. (default: master)
--github-subdir=GITHUB-SUBDIR
subdirectory within repo that contains the R package. (default: NULL)
--github-host-api=GITHUB-HOST-API
Github API host to use. (default: api.github.com)
--github-auth-token=GITHUB-AUTH-TOKEN
personal access token (PAT) to use . (default: NULL
-u LIBS, --libs=LIBS
library directories where to install the packages.
(default: $HOME/R/x86_64-pc-linux-gnu/4.4.0-library or $R_LIBS_USER if set)
-r REPOS, --repos=REPOS
the base URL(s) of the repositories to use.
(default: http://cran.r-project.org)
-s, --from-source-pkg
install from local source pkg. (.tgz or .tar.gz only)
-h, --help
Show this help message and exit
for comments, bugs report etc... contact Eric Deveaud <edeveaud@pasteur.fr>
R_install_packages can install library packages from various sources:
- from cran repository (default)
- from bioclite repository using the
--biocliteoption flag - from github repository using the
--githuboption flag - from source archives using the --from-source-pkg option flag. In this case no dependency resolution is done. You will need to handle the dependencies by yourself.
given the requirement for internet access (cran, bioclite, github) R_install_packages must be run on maestro's submit node as maestro's exec node does not have internet access.
you may run R_install_package on compute node only if you want to install library packages from sources given you previously downloaded it and made them available elsewhere on maestro file system.
R_install_packages can install library packages to various destination.
- by default it will install libraries in
$HOME/R/x86_64-pc-linux-gnu-library/<R_VERSION>this location is part of the default R library search path. it means that once libraries are installed they will be available for your code - any other location specified via
--libsflag. in this case you must set the R_LIBS_USER=<DIR>environnement variable to let R find installed libraries.
Related articles#
Related articles appear here based on the labels you select. Click to edit the macro and add or change labels.
false5FAQAfalsemodifiedtruepagelabel in ("rcran","r") and type = "page" and space = "FAQA"R rcran
true
| Related issues |