I've been trying to install DESeq2 for differential expression analysis. Unfortunately, installation keeps failing because the dependencies can not be installed. The culprit is the XVector package, that is required for one of DESeq2's dependencies. This is the error:
# Installing
if (!requireNamespace("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install("DESeq2")
# Error
fatal error: zlib.h: No such file or directory
16 | #include <zlib.h>
| ^~~~~~~~
compilation terminated.
make: *** [/usr/local/lib/R/etc/Makeconf:172: io_utils.o] Error 1
ERROR: compilation failed for package ‘XVector’
* removing ‘/usr/local/lib/R/site-library/XVector
Due to this zlib.h file that is not found, the installation fails. I'm working in rstudio hosted from a docker container based on the rocker/rstudio:4.0.5 (newer versions like 4.1.1 throw the same error). Installing zlib by running sudo apt-get install zlib1g
in the docker container does not solve the problem, as zlib1g is already installed with the newest version.
I found that the error occurs even for an unaltered R 4.0.5, find the sessionInfo below.
> sessionInfo()
R version 4.0.5 (2021-03-31)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.3 LTS
Matrix products: default
BLAS/LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.8.so
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=C LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] BiocManager_1.30.15 compiler_4.0.5 tools_4.0.5
Has anyone found a way to deal with zlib.h issues?
Thanks for your answer, this indeed solves my problem. Initially when I tried your solution I ran into several errors relating to packages that are not available. I learned that
apt-get update
needs to be run in therocker/rstudio
based container to find the packages. Next I could runapt-get install zlib1g-dev
to solve the problem that occurred with XVector andapt-get install libxml2-dev
to deal with another error that would otherwise occur, for reference:After installing these two packages DESeq2 and all it's dependencies install without error.