1

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
gaasantana
  • 11
  • 1
  • The error tells you that the zlib library is missing. Do `sudo apt-get install zlib1g-dev` from a terminal and try again. – neilfws Oct 19 '22 at 00:23
  • The error tells you that you need the `zlib` *development support files*, which you can install with e.g. `sudo apt-get install zlib1g-dev` on Ubuntu & Mint. Once you've installed `zlib1g-dev`, there might be other errors from missing dependencies. The road to success is to iteratively install missing dependencies, or alternatively find out what are the dependencies of `writexl` and install all of them first. – Maurits Evers Oct 19 '22 at 00:25
  • @MauritsEvers, in this case `zlib1g-dev` should be the only dependency: https://libxlsxwriter.github.io/getting_started.html – jmcnamara Oct 20 '22 at 11:28
  • 1
    @jmcnamara Great, thanks for clearing this up. – Maurits Evers Oct 20 '22 at 11:57

1 Answers1

-1

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")'

dark_77
  • 9
  • 1
  • 2
    This has nothing to do with R not being *"configured with the correct C flags"* and it is unlikely that there is a *"bug in [OPs] linux installation"*. I also don't understand why you introduce docker and `zypper` to the issue here (OP mentions Mint and Fedora, not OpenSUSE, so these commands are useless for OP). When installing R packages "from source" you'll need the development headers (in this case `zlib1g-dev` and probably others). These development support files are not installed by default. This is a very common issue when installing R packages on Linux systems. – Maurits Evers Oct 20 '22 at 05:44