0

When I trying to install package Rsamtools, I encountered this error:

> BiocManager::install('Rsamtools')
Bioconductor version 3.12 (BiocManager 1.30.12), ?BiocManager::install for help
'getOption("repos")' replaces Bioconductor standard repositories, see
'?repositories' for details

replacement repositories:
    CRAN: https://cloud.r-project.org

Bioconductor version 3.12 (BiocManager 1.30.12), R 4.0.4 (2021-02-15)
Installing package(s) 'Rsamtools'
also installing the dependency ‘Rhtslib’

trying URL 'https://bioconductor.org/packages/3.12/bioc/src/contrib/Rhtslib_1.22.0.tar.gz'
Content type 'application/x-gzip' length 1472143 bytes (1.4 MB)
==================================================
downloaded 1.4 MB

trying URL 'https://bioconductor.org/packages/3.12/bioc/src/contrib/Rsamtools_2.6.0.tar.gz'
Content type 'application/x-gzip' length 2906572 bytes (2.8 MB)
==================================================
downloaded 2.8 MB

* installing *source* package ‘Rhtslib’ ...
** using non-staged installation via StagedInstall field
** libs
cd "htslib-1.7" && make -f "/usr/lib/R/etc/Makeconf" -f "Makefile.Rhtslib"
make[1]: Entering directory '/tmp/RtmphSYt1J/R.INSTALLc46363cf91e5/Rhtslib/src/htslib-1.7'
Makefile.Rhtslib:128: warning: overriding recipe for target '.c.o'
/usr/lib/R/etc/Makeconf:172: warning: ignoring old recipe for target '.c.o'
gcc -std=gnu99 -g -O2 -fdebug-prefix-map=/build/r-base-fhxXXR/r-base-4.0.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -fpic -I.  -D_FILE_OFFSET_BITS=64 -c -o kfunc.o kfunc.c
gcc -std=gnu99 -g -O2 -fdebug-prefix-map=/build/r-base-fhxXXR/r-base-4.0.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -fpic -I.  -D_FILE_OFFSET_BITS=64 -c -o knetfile.o knetfile.c
gcc -std=gnu99 -g -O2 -fdebug-prefix-map=/build/r-base-fhxXXR/r-base-4.0.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -fpic -I.  -D_FILE_OFFSET_BITS=64 -c -o kstring.o kstring.c
gcc -std=gnu99 -g -O2 -fdebug-prefix-map=/build/r-base-fhxXXR/r-base-4.0.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -fpic -I.  -D_FILE_OFFSET_BITS=64 -c -o bcf_sr_sort.o bcf_sr_sort.c
gcc -std=gnu99 -g -O2 -fdebug-prefix-map=/build/r-base-fhxXXR/r-base-4.0.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -fpic -I.  -D_FILE_OFFSET_BITS=64 -c -o bgzf.o bgzf.c
In file included from bgzf.c:39:
htslib/bgzf.h:35:10: fatal error: zlib.h: No such file or directory
 #include <zlib.h>
          ^~~~~~~~
compilation terminated.
make[1]: *** [Makefile.Rhtslib:128: bgzf.o] Error 1
make[1]: Leaving directory '/tmp/RtmphSYt1J/R.INSTALLc46363cf91e5/Rhtslib/src/htslib-1.7'
make: *** [Makevars.common:24: htslib] Error 2
ERROR: compilation failed for package ‘Rhtslib’
* removing ‘/usr/local/lib/R/site-library/Rhtslib’
ERROR: dependency ‘Rhtslib’ is not available for package ‘Rsamtools’
* removing ‘/usr/local/lib/R/site-library/Rsamtools’

The downloaded source packages are in
    ‘/tmp/Rtmpq79sQU/downloaded_packages’
Warning messages:
1: In install.packages(...) :
  installation of package ‘Rhtslib’ had non-zero exit status
2: In install.packages(...) :
  installation of package ‘Rsamtools’ had non-zero exit status

From what I found, the library zlib1g-dev already installed in my computer does not create zlib.h at the folder R running the compile. However, all the solution I found was for compile on bash command, not on R and I don't know how to solve this solution. Can anyone help me, please.

  • You need to run the bash commands in your terminal first and then reinstall via `BiocManager::install('Rsamtools')` in your R console : https://stackoverflow.com/questions/36374267/how-to-fix-fatal-error-zlib-h-no-such-file-or-directory – Basti Apr 07 '21 at 08:36
  • I have follow that post previously before I made this post. It only solve the problem when compile on bash command, not in R console. – khanhlpbao Apr 07 '21 at 08:45

0 Answers0