rstudio / htmltools

Tools for HTML generation and output
https://rstudio.github.io/htmltools/
214 stars 67 forks source link

Cannot install htmltools 0.5.5 due to a compilation error #373

Closed ccamara closed 1 year ago

ccamara commented 1 year ago

I have just started a new project, with a blank environment. When running install.packages("htmltools") I get the following error:

Installing htmltools [0.5.5] ...
    FAILED
Error installing package 'htmltools':
=====================================

* installing *source* package ‘htmltools’ ...
** package ‘htmltools’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
gcc-5.3.0  -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I/opt/R/arm64/include   -fPIC  -mtune=native -g -O2 -Wall -pedantic -Wconversion -c init.c -o init.o
/bin/sh: gcc-5.3.0: command not found
make: *** [init.o] Error 127
ERROR: compilation failed for package ‘htmltools’
* removing ‘/Users/<path>/renv/staging/1/htmltools’
Error: install of package 'htmltools' failed [error code 1]

This is my sessionInfo:

> sessionInfo()
R version 4.2.2 (2022-10-31)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Ventura 13.1

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices datasets  utils     methods   base     

loaded via a namespace (and not attached):
[1] compiler_4.2.2 tools_4.2.2    renv_0.16.0   
> 

From what I seem to understand, the package cannot be compiled because there's an issue with gcc.

I'm not 100% sure of what it is, but I checked and gcc is installed:

$ which gcc
/usr/bin/gcc

however, gcc-5.3.0 doesn't seem to be a valid command (zsh: command not found: gcc-5.3.0)

wch commented 1 year ago

The compiler is determined by your R installation. I think you will have the same problem installing any package that has compiled code (if you are installing from source).

Can you just install the binary package? I see on CRAN it is currently on the previous version, 0.5.4, but that should be OK for most people.

ccamara commented 1 year ago

Thanks for your answer, @wch ! I re-installed R and it is working now. I do not remember how did I install it (I'm not very familiar with Macs) and in my case, I had to re-install it via brew install --cask r and it worked fine.