Homebrew R build missing Cairo
Asked Answered
I

2

5

I installed R on an OSX 10.7.5 server using brew:

brew install R

Everything seems so OK far, however Cairo is not working:

> svg(tempfile())
Warning messages:
1: In svg(tempfile()) :
  unable to load shared object '/usr/local/Cellar/r/2.15.2/R.framework/Resources/library/grDevices/libs//cairo.so':
  dlopen(/usr/local/Cellar/r/2.15.2/R.framework/Resources/library/grDevices/libs//cairo.so, 6): image not found
2: In svg(tempfile()) : failed to load cairo DLL

The shared object file seems to be missing completely:

id-86-243:Resources jeroen$ ls -ltr library/grDevices/libs/
total 488
-rwxrwxr-x  1 jeroen  admin  245764 Dec 22 17:03 grDevices.so

I rarely use OSX, so I am not quite sure if this is a bug in this particular distribution of R, or if I have done something wrong when building it?

Illumination answered 23/12, 2012 at 8:20 Comment(5)
ISTR that Simon Urbanek discourages people from using homebrew to compile R. On Nov 4 2012 in the MacSIG he wrote: "You can't use CRAN binaries with homebrew. If you use homebrew, you're entirely on your own and you have to build everything from sources."Heart
That's fine. In Linux we always install packages from source as well. grDevices is base R though.Illumination
The default packages include both 'base' and 'grDevices', but grDevices is not in the 'base' package.Heart
When installing R using macports, I have to make sure that I install r-framework and not just R. Maybe there is a similar issue with brew? I suggest to use macports.Gomes
@DWin I was referring to its priority: svn.r-project.org/R/trunk/src/library/grDevices/DESCRIPTION.inIllumination
C
9

I just ran into this problem. It seems to be a problem with pkg-config locating cairo during the R configure stage. The workaround seems to be:

export PKG_CONFIG_PATH=/opt/X11/lib/pkgconfig

so that R can properly use cairo.

I install R directly from source, rather than with homebrew, but I do use homebrew to keep other libraries up to date. This resolves the problem for me.

For reference, I am running OSX Mavericks.

Counteract answered 10/12, 2013 at 22:45 Comment(1)
Installing from source in homebrew (i.e. as brew install R --build-from-source) caused R to be linked to the appropriate cairo library for me.Convexoconvex
R
1

What finally worked for me was building R explicitly with cairo (brew's default R tap uses --without-cairo and simply editing the tap did not solve the issue for me).

It's all explained in this nice blog post: https://luispuerto.net/blog/2018/05/11/installing-r-with-homebrew-with-all-the-capabilities/

Works like a charm for me with R 4.0.2, cairo 1.16.0_3 under macOS Catalina 10.15.6.

Retinoscopy answered 9/10, 2020 at 13:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.