1

I am trying to install ggplot package in R but I got the following error

install.packages('ggplot2',dependencies = TRUE)



* installing *source* package ‘gdtools’ ...
** package ‘gdtools’ successfully unpacked and MD5 sums checked
Using PKG_CFLAGS=-I/usr/local/opt/cairo/include/cairo
Using PKG_LIBS=-L/usr/local/opt/cairo/lib -lcairo
** libs
clang++ -I/usr/local/Cellar/r/3.3.1_2/R.framework/Resources/include -DNDEBUG -I/usr/local/opt/cairo/include/cairo -I../inst/include/ -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/openssl/include -I/usr/local/include -I"/usr/local/lib/R/3.3/site-library/Rcpp/include"   -fPIC  -g -O2  -c CairoContext.cpp -o CairoContext.o
clang++ -I/usr/local/Cellar/r/3.3.1_2/R.framework/Resources/include -DNDEBUG -I/usr/local/opt/cairo/include/cairo -I../inst/include/ -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/openssl/include -I/usr/local/include -I"/usr/local/lib/R/3.3/site-library/Rcpp/include"   -fPIC  -g -O2  -c RcppExports.cpp -o RcppExports.o
clang++ -I/usr/local/Cellar/r/3.3.1_2/R.framework/Resources/include -DNDEBUG -I/usr/local/opt/cairo/include/cairo -I../inst/include/ -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/openssl/include -I/usr/local/include -I"/usr/local/lib/R/3.3/site-library/Rcpp/include"   -fPIC  -g -O2  -c font_metrics.cpp -o font_metrics.o
In file included from font_metrics.cpp:3:
/usr/local/opt/cairo/include/cairo/cairo-ft.h:46:10: fatal error: 'ft2build.h'
      file not found
#include <ft2build.h>
         ^
1 error generated.
make: *** [font_metrics.o] Error 1
ERROR: compilation failed for package ‘gdtools’
* removing ‘/usr/local/lib/R/3.3/site-library/gdtools’
* installing *source* package ‘ggplot2’ ...
** package ‘ggplot2’ successfully unpacked and MD5 sums checked
** R
** data
*** moving datasets to lazyload DB
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
* DONE (ggplot2)
ERROR: dependency ‘gdtools’ is not available for package ‘svglite’
* removing ‘/usr/local/lib/R/3.3/site-library/svglite’

The downloaded source packages are in
    ‘/private/var/folders/mm/8gjs_s_s01x3_qr4xrdky88c0000gn/T/RtmpwQObj5/downloaded_packages’
Warning messages:
1: In install.packages("ggplot2", dependencies = TRUE) :
  installation of package ‘gdtools’ had non-zero exit status
2: In install.packages("ggplot2", dependencies = TRUE) :
  installation of package ‘svglite’ had non-zero exit status

I installed R by following the instruction in this page: Installing R with Homebrew

brew tap homebrew/science
brew install Caskroom/cask/xquartz
brew install r

Can anyone shed me some light on this? thanks so much!

Community
  • 1
  • 1
Tommy Tang
  • 111
  • 8
  • That first error seems to indicate problems with cairo libraries missing. If you google "homebrew r cairo" you get hits like [this](https://github.com/Homebrew/homebrew-science/issues/1890) or [this](http://stackoverflow.com/questions/14009606/homebrew-r-build-missing-cairo) which you may find helpful – MrFlick Sep 07 '16 at 21:22
  • 1
    Or [this](https://github.com/Homebrew/legacy-homebrew/issues/5739) suggests it could be an X11 problem. Have you installed [XQuartz](https://www.xquartz.org/)? – MrFlick Sep 07 '16 at 21:26
  • Thanks @MrFlick. Yes I found similar discussions before so I have installed cario, freetype2 and xquartz using homebrew. Still not work, I think the build process above is not referring to the paths of homebrew installations, and thus it fails. – Tommy Tang Sep 08 '16 at 02:40
  • The error above seems hinted it is using cairo in following paths. I do have cairo in these paths already. `Using PKG_CFLAGS=-I/usr/local/opt/cairo/include/cairo` `(Using PKG_LIBS=-L/usr/local/opt/cairo/lib -lcairo)` – Tommy Tang Sep 08 '16 at 02:46

0 Answers0