Appendix C — Installation troubleshooting
First of all, please ensure that you have an up-to-date version of R (the notes below were tested on R 4.3–4.4; see the session info of each section).
C.1 Mac M1 user
When attempting to install miaverse packages, you may encounter installation failures related to the ‘scuttle’ and ‘scater’ dependencies, which require a gcc compiler for installation. The error message might resemble the following:
ld: warning: directory not found for option
'-L/opt/gfortran/lib/gcc/aarch64-apple-darwin20.0/12.2.0'
ld: warning: directory not found for option '-L/opt/gfortran/lib'
ld: library not found for -lgfortran
clang: error: linker command failed with exit code 1 (use -v to see
invocation)
This error indicates that R is unable to locate the ‘libgfortran’ during the package compilation process. If you encounter this error, you can use the following workaround:
Install two essential tools in order to compile R for macOS as described in Mac-r-project:
- Install Xcode:
sudo xcode-select --install - Install the GNU Fortran compiler: download it from here. You can also install it from a package manager, for example Homebrew, but it is not recommended.
- Install Xcode:
Locate the gfortran using
which gfortranto find the version of gfortran that is stored in your ~/.bashrc or ~/.bash_profile. Make sure it points to the gfortran that you want to use. For example if you have both homebrew and mac-r project gfortran, you may want to add the mac-r project gfortran to your $PATH variable.- Add
export PATH="/opt/gfortran/bin:$PATH"to your ~/.bash_profile or ~/.bashrc, followed bysource ~/.bash_profilein your terminal.
- Add
Modify your
/Library/Frameworks/R.framework/Resources/etc/Makeconffrom:
FLIBS = -L/opt/R/arm64/gfortran/lib/gcc/aarch64-apple-darwin20.2.0/11.0.0 -L/opt/R/arm64/gfortran/lib -lgfortran -lemutls_w -lmto*:
FLIBS = -L/opt/gfortran/lib/gcc/aarch64-apple-darwin20.0/12.2.0 -L/opt/gfortran/lib -lgfortran -lm -lquadmath*note that the path depends on your installation site, sometimes it is located in
/usr/local/gfortran/libso you have to change/opt/gfortran/libaccordingly in the lines above.
After all of those steps, you can follow the installation instructions on the Bioconductor page. For example, for the mia package:
if (!require("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install("mia")
If the installation prompts you to compile from source, you can answer yes, and hopefully it can be successfully compiled. Good luck!
Follow-up reading:
- https://support.bioconductor.org/p/9138121/
- https://medium.com/biosyntax/following-up-library-dependency-when-compiling-r-packages-89f191b9f227
Session info at the time of writing:
> sessionInfo()
R version 4.3.1 (2023-06-16)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Big Sur 11.6
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.11.0
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
time zone: Europe/Helsinki
tzcode source: internal
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_4.3.1 bookdown_0.36 fastmap_1.1.1 cli_3.6.1
[5] htmltools_0.5.6.1 tools_4.3.1 rstudioapi_0.15.0 yaml_2.3.7
[9] rmarkdown_2.25 knitr_1.44 xfun_0.40 digest_0.6.33
[13] rlang_1.1.1 evaluate_0.22
C.2 Windows user
Windows users commonly encounter Rtools-related issues when installing miaverse packages that contain C++ code. Rtools is a collection of software tools required for building R packages from source on Windows.
C.2.1 Common Rtools error messages
You may see warnings like:
WARNING: Rtools is required to build R packages but is not currently installed.
Please download and install the appropriate version of Rtools before proceeding:
https://cran.rstudio.com/bin/windows/Rtools/
Or during compilation:
Error: Failed to compile C++ code
fatal error: R.h: No such file or directory
compilation terminated.
C.2.2 Rtools installation steps
Determine your R version by running in R console:
R.version.stringDownload the correct Rtools version from https://cran.r-project.org/bin/windows/Rtools/. Rtools must match your R version:
- For R 4.5: Use Rtools45
- For R 4.4: Use Rtools44
- For R 4.3: Use Rtools43
- For R 4.2: Use Rtools42
- For R 4.0-4.1: Use Rtools40
- For R 3.5-3.6: Use Rtools35
Install Rtools:
- Run the downloaded installer (e.g.,
rtools44-6104-6039.exe) - Important: Use the default installation path (e.g.,
C:\rtools44) - Accept all default settings during installation
- Allow the installer to modify your system PATH when prompted
- Run the downloaded installer (e.g.,
Verify Rtools installation in R console:
# Check if Rtools is found Sys.which("make") # For more detailed verification pkgbuild::find_rtools()
C.2.3 Troubleshooting Rtools issues
If Rtools is not detected after installation:
Check PATH environment variable:
Sys.getenv("PATH")Should include paths like
C:\rtools44\usr\binandC:\rtools44\x86_64-w64-mingw32.static.posix\binManual PATH setup using .Renviron file (recommended approach):
# Add a line to the .Renviron file (creates the file if needed) cat( 'PATH="${RTOOLS44_HOME}\\usr\\bin;${PATH}"\n', file = "~/.Renviron", append = TRUE )Alternative manual PATH setup for current session:
# Add Rtools to PATH for current session Sys.setenv(PATH = paste(Sys.getenv("PATH"), "C:\\rtools44\\usr\\bin", "C:\\rtools44\\x86_64-w64-mingw32.static.posix\\bin", sep = ";"))Restart R/RStudio after installation and PATH configuration for changes to take effect.
C.2.4 Alternative solutions
Use pre-compiled binaries: If possible, install binary versions of packages instead of compiling from source:
install.packages("package_name", type = "binary")Docker approach: Use the Docker installation as described in the Linux section below, which avoids compilation issues entirely.
C.2.5 Common issues and solutions
- Anti-virus interference: Some anti-virus software may block Rtools installation. Temporarily disable it during installation.
- Permissions: Ensure you have administrator rights when installing Rtools.
- Network restrictions: In corporate environments, download restrictions may prevent automatic Rtools installation.
- Mixed architectures: Ensure Rtools architecture (64-bit) matches your R installation.
- Username with spaces: Windows usernames with spaces can cause issues. Consider editing TMP and TEMP environment variables to a location without spaces, like
C:\TEMP.
C.2.6 Testing Rtools installation
After successful installation, test with a simple package compilation:
# Test with Rcpp compilation
install.packages("Rcpp")
library(Rcpp)
# Test compilation
Rcpp::evalCpp("1 + 1")If this returns 2, your Rtools installation is working correctly.
After successful Rtools setup, install miaverse packages:
if (!require("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install("mia")Session info at the time of writing:
> sessionInfo()
R version 4.4.1 (2024-06-14)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 11 x64 (build 22631)
Matrix products: default
BLAS: C:/Program Files/R/R-4.4.1/bin/x64/Rblas.dll
LAPACK: C:/Program Files/R/R-4.4.1/bin/x64/Rlapack.dll; LAPACK version 3.12.0
locale:
[1] LC_COLLATE=English_United States.utf8 LC_CTYPE=English_United States.utf8
[3] LC_MONETARY=English_United States.utf8 LC_NUMERIC=C
[5] LC_TIME=English_United States.utf8
time zone: America/New_York
tzcode source: internal
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_4.4.1
C.3 Linux user
The easiest method to run this book is by using Docker. See instructions in README. It is recommended to try using Docker before attempting the steps below.
On Linux, most packages require compilation from source. To do so, the system requires a series of libraries. Below, you will find the commands that will install the required packages. There is a good chance that distributions based on the ones described below also require the same packages.
C.3.1 Ubuntu
It was tested on Ubuntu 24.04.2 (Noble Numbat).
sudo apt update
sudo apt install -y \
cmake \
libxml2-dev libssl-dev \
libgsl-dev \
libgmp-dev \
libcairo2-dev \
libharfbuzz-dev \
libfribidi-dev \
libmpfr-dev \
libfreetype6-dev libpng-dev libtiff5-dev libjpeg-dev \
default-jdkSession info at the time of writing:
> sessionInfo()
R version 4.4.3 (2025-02-28)
Platform: x86_64-pc-linux-gnu
Running under: Ubuntu 24.04.2 LTS
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.12.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.12.0
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
time zone: Europe/Helsinki
tzcode source: system (glibc)
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_4.4.3
For Ubuntu packages, please see here.
C.3.2 Debian
It was tested on Debian 12.10 (Bookworm).
sudo apt install -y \
cmake \
libgmp-dev \
libssl-dev \
libgsl-dev \
libcurl4-openssl-dev \
libnode-dev \
libmpfr-dev \
libcairo2-dev \
libharfbuzz-dev \
libfribidi-dev \
libfreetype6-dev \
libpng-dev \
libtiff5-dev \
libxml2-dev \
default-jdkSession info at the time of writing:
> sessionInfo()
R version 4.4.3 (2025-02-28)
Platform: x86_64-pc-linux-gnu
Running under: Debian GNU/Linux 12 (bookworm)
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.11.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.11.0
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
time zone: Europe/Helsinki
tzcode source: system (glibc)
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_4.4.3
C.3.3 Fedora
It was tested on Fedora 41.
sudo dnf install -y \
cmake \
openssl-devel \
fontconfig-devel \
curl-devel \
gmp-devel \
gsl-devel \
mpfr-devel \
v8-devel \
fribidi-devel \
libjpeg-turbo-devel \
freetype-devel \
libpng-devel \
libtiff-devel \
libjpeg-develSession info at the time of writing:
> sessionInfo()
R version 4.4.3 (2025-02-28)
Platform: x86_64-redhat-linux-gnu
Running under: Fedora Linux 41 (KDE Plasma)
Matrix products: default
BLAS/LAPACK: FlexiBLAS OPENBLAS-OPENMP; LAPACK version 3.12.0
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
time zone: Europe/Helsinki
tzcode source: system (glibc)
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_4.4.3