Search code examples
rtravis-cibookdowntikz

Travis CI not working for bookdown when using tikz environement


When adding a tikz picture environment in bookdown, my Travis CI build stops working.

Here is the error.

Error in loadNamespace(name) : there is no package called 'magick'
Calls: <Anonymous> ... loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart
Execution halted
The command "Rscript -e 'bookdown::render_book("index.Rmd")'" exited with 1.

I tried adding the magick package to my DESCRIPTION file like this:

- Imports: 
    bookdown,
    magick

or like that

- Remotes:
    ropensci/magick

My build is still not working.

The easiest way to reproduce the problem is to clone the repo bookdown_travis. When building the book in RStudio, everything works but I receive an error message on Travis CI.

The problem is in the 07-tikz.Rmd file. This file contains a minimal tikz example that should be working.

Thanks in advance for your help.


Solution

  • Looking at the actual build logs we see:

    ------------------------- ANTICONF ERROR ---------------------------
    Configuration failed because Magick++ was not found. Try installing:
     - deb: 'libmagick++-dev' (Debian, Ubuntu)
     - rpm: 'ImageMagick-c++-devel' (Fedora, CentOS, RHEL)
     - csw: 'imagemagick_dev' (Solaris)
    On MacOS it is recommended to use install ImageMagick-6 from homebrew
    with extra support for fontconfig and rsvg rendering:
       brew reinstall imagemagick@6 --with-fontconfig --with-librsvg
    For older Ubuntu versions Trusty (14.04) and Xenial (16.04) use our PPA:
       sudo add-apt-repository -y ppa:opencpu/imagemagick
       sudo apt-get update
       sudo apt-get install -y libmagick++-dev
    If Magick++ is already installed, check that 'pkg-config' is in your
    PATH and PKG_CONFIG_PATH contains a Magick++.pc file. If pkg-config
    is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
    R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
    --------------------------------------------------------------------
    

    Since Travis CI uses Xenial, you should use

    addons:
      apt:
        sources:
        - sourceline: 'ppa:opencpu/imagemagick'
        packages:
        - libmagick++-dev
    

    in .travis.yml. You will probably have to repeat this process for other packages that require system libraries.