Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build R with cairo device on Mac OS #3573

Closed
andreyto opened this issue Oct 3, 2016 · 10 comments
Closed

Build R with cairo device on Mac OS #3573

andreyto opened this issue Oct 3, 2016 · 10 comments
Assignees
Labels
locked [bot] locked due to inactivity

Comments

@andreyto
Copy link

andreyto commented Oct 3, 2016

R is currently not built with cairo support on Mac OS, as can be seen from the source (https://github.com/conda/conda-recipes/blob/a796713805ac8eceed191c0cb475b51f4d00718c/r-base/build.sh).
As a result, it is not possible to use svg() on Mac OS. Is there any specific reason why --with-cairo is not passed to configure script?
Thanks!

@mingwandroid mingwandroid self-assigned this Oct 3, 2016
@mingwandroid
Copy link
Contributor

The reason, to the best of my knowledge, is that on macOS, building R with Cairo requires enabling X11 and XQuartz is not something we've wanted to force people to install (and I do not know what issues it would cause me).

Personally, rather than requiring XQuartz, I would rather investigate removing this X11 dependency.

@csoja, just making you aware of this.

@andreyto
Copy link
Author

andreyto commented Oct 4, 2016

If it can help, at least on Linux without X11 installed, this worked for me before:

configopts = "--with-lapack --with-blas --with-pic --enable-threads --with-x=no --enable-R-shlib"
configopts += " --with-cairo --with-libpng --with-libtiff --with-jpeglib"
configopts += " --with-recommended-packages=no"

and then:

$ less ~/.Rprofile 
options(bitmapType="cairo")

If I am reading it correctly, Homebrew can build R on MacOS with Cairo device and without X11
(https://github.com/Homebrew/homebrew-science/blob/master/r.rb)

    # Fix cairo detection with Quartz-only cairo
    inreplace ["configure", "m4/cairo.m4"], "cairo-xlib.h", "cairo.h"

where "Quarz-only Cairo" is built here: (https://github.com/Homebrew/homebrew-core/blob/master/Formula/cairo.rb)

Capabilities() from the default R build that I installed from Homebrew:

> capabilities()
       jpeg         png        tiff       tcltk         X11        aqua    http/ftp     sockets      libxml        fifo      cledit       iconv         NLS     profmem 
       TRUE        TRUE        TRUE        TRUE       FALSE        TRUE        TRUE        TRUE        TRUE        TRUE        TRUE        TRUE        TRUE        TRUE 
      cairo         ICU long.double     libcurl 
       TRUE        TRUE        TRUE        TRUE 

@mingwandroid
Copy link
Contributor

Interesting. Thanks for the pointers!

@asifzubair
Copy link

I am having this problem on CentOS as well. I upgraded my R version and now Rmarkdown doesn't work now

(1)> Rscript -e 'rmarkdown::render("temp.Rmd")'

processing file: temp.Rmd
  |................................                                 |  50%
   inline R code fragments

  |.................................................................| 100%
label: knitr (with options)
List of 4
 $ include: logi FALSE
 $ echo   : logi FALSE
 $ message: logi FALSE
 $ warning: logi FALSE

Quitting from lines 9-11 (temp.Rmd)
Error in .External2(C_X11, paste("png::", filename, sep = ""), g$width,  :
  unable to start device PNG
Calls: <Anonymous> ... block_exec -> chunk_device -> dev_new -> do.call -> <Anonymous>
In addition: Warning messages:
1: In grDevices::png(tempfile()) :
  unable to open connection to X11 display ''
2: In (function (filename = "Rplot%03d.png", width = 480, height = 480,  :
  unable to open connection to X11 display ''

Execution halted

This thread confirms the reason for the above error:

From my experience, that is often an indication that you built R from
source but didn't pay attention to the cairo/pango dependencies

also, this is the capabilities:

> capabilities()
       jpeg         png        tiff       tcltk         X11        aqua 
      FALSE       FALSE       FALSE        TRUE       FALSE       FALSE 
   http/ftp     sockets      libxml        fifo      cledit       iconv 
       TRUE        TRUE        TRUE        TRUE        TRUE        TRUE 
        NLS     profmem       cairo         ICU long.double     libcurl 
       TRUE        TRUE       FALSE        TRUE        TRUE        TRUE 

It will be great if a new build can be pushed with the cairo dependency

@andreyto
Copy link
Author

andreyto commented Oct 29, 2016

I have created the modified Cairo and R recipes, following equivalent
solutions from the Homebrew. The main thing was that the configure script
in R 3.3.1 had to be patched because in that version of R it hard-wired a
check for cairo-xlib.h, which was failing and Cairo was getting disabled in
the build. I now have R recipe that can be built and used with svg()
devices on a headless server that does not have any X11 libs installed. I will
polish the recipe a bit to make it somewhat more general (maybe using a
"feature" tag?), and submit a pull request. I do not want to simply make a
clone of the existing recipe.

On Sat, Oct 29, 2016 at 2:37 AM, Asif Zubair notifications@github.com
wrote:

I am having this problem on CentOS as well. I upgraded my R version and
now Rmarkdown doesn't work now

(1)> Rscript -e 'rmarkdown::render("temp.Rmd")'

processing file: temp.Rmd
|................................ | 50%
inline R code fragments

|.................................................................| 100%
label: knitr (with options)
List of 4
$ include: logi FALSE
$ echo : logi FALSE
$ message: logi FALSE
$ warning: logi FALSE

Quitting from lines 9-11 (temp.Rmd)
Error in .External2(C_X11, paste("png::", filename, sep = ""), g$width, :
unable to start device PNG
Calls: ... block_exec -> chunk_device -> dev_new -> do.call ->
In addition: Warning messages:
1: In grDevices::png(tempfile()) :
unable to open connection to X11 display ''
2: In (function (filename = "Rplot%03d.png", width = 480, height = 480, :
unable to open connection to X11 display ''

Execution halted

This thread
http://r.789695.n4.nabble.com/Error-in-External2-C-X11-paste-quot-png-quot-filename-sep-quot-quot-g-width-unable-to-start-device-PG-td4710983.html
confirms the reason for the above error:

From my experience, that is often an indication that you built R from
source but didn't pay attention to the cairo/pango dependencies

also, this is the capabilities:

capabilities()
jpeg png tiff tcltk X11 aqua
FALSE FALSE FALSE TRUE FALSE FALSE
http/ftp sockets libxml fifo cledit iconv
TRUE TRUE TRUE TRUE TRUE TRUE
NLS profmem cairo ICU long.double libcurl
TRUE TRUE FALSE TRUE TRUE TRUE

It will be great if a new build can be pushed with the cairo dependency


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#3573 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAIW0NJwoykvth1CpPEMo4LNFnZS3xtyks5q4umagaJpZM4KNIf-
.

@mingwandroid
Copy link
Contributor

Great.

@mingwandroid
Copy link
Contributor

mingwandroid commented Dec 2, 2016

Following the homebrew approach for macOS failed miserably for me. To build a cairo enabled R for macOS apart from a newer cairo I also needed to build fontconfig, gettext, glib, harfbuzz, libffi, pango and pixman.

If you are on macOS, you can try a cairo-enabled r-base now if you wish *:

conda install -c rdonnellyr r-base

Testing and feedback would be appreciated. Linux to follow but it may not be ready until Monday. While you're at it, testing rstudio (from the normal r channel) would also be helpful.

* I would recommend doing this in a throwaway installation of Miniconda or Anaconda for now and not in something mission critical (so you should create another installation then install `r-essentials from the normal r channel into that first).

@andreyto
Copy link
Author

andreyto commented Dec 3, 2016

Sorry, I forgot to share my own fix. This is the code that gets me svg() device in R 3.3.1 on Linux (CentOS 6) that does not have X11 libs installed. I never tried on Mac OS.
andreyto/conda-recipes@80f982e

@mingwandroid
Copy link
Contributor

This is fixed now, closing.

@github-actions
Copy link

github-actions bot commented Nov 6, 2021

Hi there, thank you for your contribution to Conda!

This issue has been automatically locked since it has not had recent activity after it was closed.

Please open a new issue if needed.

@github-actions github-actions bot added the locked [bot] locked due to inactivity label Nov 6, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
locked [bot] locked due to inactivity
Projects
None yet
Development

No branches or pull requests

3 participants