Search code examples
rcondacairo

Cannot find cairo.h


Common problem, but there's no solution for me so far - so maybe you can help a lost bioinformatician with rather little experience in IT stuff. I need to install Cairo in my R environment (R version 4.1.1) on my mac Big Sur 11.5.1 and get this error:

> install.packages("Cairo")
...
checking for pkg-config... /usr/local/bin/pkg-config
checking whether pkg-config knows about cairo... no
configure: CAIRO_LIBS is unset, attempting to guess it.
configure: CAIRO_CFLAGS=
checking if R was compiled with the RConn patch... no
checking cairo.h usability... no
checking cairo.h presence... no
checking for cairo.h... no
configure: error: Cannot find cairo.h! Please install cairo (http://www.cairographics.org/) and/or set CAIRO_CFLAGS/LIBS correspondingly.
ERROR: configuration failed for package ‘Cairo’
* removing ‘/Users/thomaslordick/opt/anaconda3/envs/seurat4/lib/R/library/Cairo’

The downloaded source packages are in
    ‘/private/var/folders/48/5h26d5297_92l76cvyjqvk2h0000gp/T/RtmpD4g5aI/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
Warnmeldung:
In install.packages("Cairo") :
  installation of package ‘Cairo’ had non-zero exit status

I already installed cairo-devel via sudo port install cairo, installed cairo via brew and also checked out similar threads (https://stat.ethz.ch/pipermail/r-help/2014-April/374096.html), where people recommend:

*Make sure you have cairo-devel installed, and remove the lines

export CAIRO_LIBS=${HOME}/usr/local/lib export CAIRO_CFLAGS=${HOME}/usr/local/include

from your .bashrc file.*

I cant find a .bashrc file when using ls -la ~/... .

According to the above mentioned error I need to specify CAIRO_LIBS and CAIRO_CFLAGS. But where can I do this?

Thanks in advance, Thomas


Solution

  • If using Conda for R environments, you are better off avoiding install.packages and instead make a point to always install through Conda. CRAN's Cairo package goes by r-cairo on Conda Forge. So,

    conda install -n seurat4 -c conda-forge r-cairo