hammer / test-book

https://blissful-einstein-69cf1e.netlify.com/
0 stars 0 forks source link

Add image #2

Open hammer opened 6 years ago

hammer commented 6 years ago

Added images/ directory and added image to document with knitr::include_graphics. Locally, the images/ directory is copied into _book/ during the build process; on Travis, it's not

hammer commented 6 years ago

One clue:

Output created: _book/test-book.epub
Warning message:
In system2(cmd, args = args, stdout = if (quiet) FALSE else "") :
  error in running command

Given how weird R can be with warnings I can't be sure this warning didn't come from the site build rather than the epub build. I can try turning warnings into errors w/ options(warn=2) to investigate...

Looks like the error is happening during figure generation for the PDF:

!!! Error: Ghostscript exited with error code 127!
Quitting from lines 50-52 (test-book.Rmd) 
Error in system2(cmd, args = args, stdout = if (quiet) FALSE else "") : 
  (converted from warning) error in running command
Calls: <Anonymous> ... <Anonymous> -> in_base_dir -> in_dir -> plot_crop -> system2
Execution halted
The command "Rscript -e 'options(warn=2); rmarkdown::render_site(encoding = "UTF-8")'" exited with 1.

Unfortunately I can't run a build in debug mode, as I'm getting "access denied" from the Travis API using tokens generated from the CLI as well as those on my account settings page.

hammer commented 6 years ago

Possibly similar issue: https://stackoverflow.com/questions/50978999/path-to-images-in-bookdown-build-through-travis

hammer commented 6 years ago

Perhaps due to the version of Pandoc? Can check w/ rmarkdown::pandoc_version().

In my local RStudio, I've got 1.19.2.1. On Travis, they have 2.2. You can grab a tarball with a compiled version of Pandoc 2.2 from https://github.com/jgm/pandoc/releases/tag/2.2.

Note that RStudio ships with its own Pandoc and sets the RSTUDIO_PANDOC environment variable to point to this location. Here's the code for how rmarkdown finds pandoc: https://github.com/rstudio/rmarkdown/blob/master/R/pandoc.R#L550. And here's how they find pandoc-citeproc: https://github.com/rstudio/rmarkdown/blob/master/R/pandoc.R#L673.

When I build locally with 2.2 I don't see any issues in copying the files over.

hammer commented 6 years ago

Maybe it's due to the use of include_graphics? I'm trying now with <img>, since that's what stat545 is using, and it seems to work for them.

It actually was the use of the private method knitr:::pandoc_to in the R chunk calling include_graphics. I'm not sure why this was working locally but not on Travis...