Package "writexl" don't install in R (Linux)

580 views Asked by At

I am trying to install the "writexl" package in my system to use in my college. The RStudio give an error, and don't install. Using Linux Mint 21, but I tried on Fedora 36 too. The output from RStudio:

> install.packages("writexl")
Installing package into ‘/home/scott/R/x86_64-pc-linux-gnu-library/4.2’
(as ‘lib’ is unspecified)
tentando a URL 'https://cloud.r-project.org/src/contrib/writexl_1.4.1.tar.gz'
Content type 'application/x-gzip' length 258461 bytes (252 KB)
==================================================
downloaded 252 KB

* installing *source* package ‘writexl’ ...
** package ‘writexl’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
gcc -I"/usr/share/R/include" -DNDEBUG -Iinclude -DUSE_R_LANG    -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c write_xlsx.c -o write_xlsx.o
gcc -I"/usr/share/R/include" -DNDEBUG -Iinclude -DUSE_R_LANG    -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c libxlsxwriter/app.c -o libxlsxwriter/app.o
gcc -I"/usr/share/R/include" -DNDEBUG -Iinclude -DUSE_R_LANG    -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c libxlsxwriter/format.c -o libxlsxwriter/format.o
gcc -I"/usr/share/R/include" -DNDEBUG -Iinclude -DUSE_R_LANG    -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c libxlsxwriter/theme.c -o libxlsxwriter/theme.o
gcc -I"/usr/share/R/include" -DNDEBUG -Iinclude -DUSE_R_LANG    -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c libxlsxwriter/chart.c -o libxlsxwriter/chart.o
gcc -I"/usr/share/R/include" -DNDEBUG -Iinclude -DUSE_R_LANG    -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c libxlsxwriter/hash_table.c -o libxlsxwriter/hash_table.o
gcc -I"/usr/share/R/include" -DNDEBUG -Iinclude -DUSE_R_LANG    -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c libxlsxwriter/utility.c -o libxlsxwriter/utility.o
gcc -I"/usr/share/R/include" -DNDEBUG -Iinclude -DUSE_R_LANG    -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c libxlsxwriter/content_types.c -o libxlsxwriter/content_types.o
gcc -I"/usr/share/R/include" -DNDEBUG -Iinclude -DUSE_R_LANG    -fvisibility=hidden -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-zYgbYq/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c libxlsxwriter/packager.c -o libxlsxwriter/packager.o
libxlsxwriter/packager.c:10:10: fatal error: zlib.h: Arquivo ou diretório inexistente
   10 | #include <zlib.h>
      |          ^~~~~~~~
compilation terminated.
make: *** [/usr/lib/R/etc/Makeconf:168: libxlsxwriter/packager.o] Erro 1
ERROR: compilation failed for package ‘writexl’
* removing ‘/home/scott/R/x86_64-pc-linux-gnu-library/4.2/writexl’
Warning in install.packages :
  installation of package ‘writexl’ had non-zero exit status
1

There are 1 answers

1
dark_77 On

Your version of R is probably not configured with the correct C flags. Can you show me the full output of the compiler before the error happens?

I have just installed the package in tumbleweed in docker and it works fine. I think it is a bug in your linux installation.

Run docker

docker run -i -t opensuse/tumbleweed bash

Run in container:

zypper update zypper install R-devel gcc zlib-devel

#install writexl R -e 'install.packages("writexl", repos = "https://cloud.r-project.org")'