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

does not check that ghostscript exists when running pdfcrop #954

Closed
dalupus opened this issue Feb 16, 2015 · 12 comments
Closed

does not check that ghostscript exists when running pdfcrop #954

dalupus opened this issue Feb 16, 2015 · 12 comments
Milestone

Comments

@dalupus
Copy link

dalupus commented Feb 16, 2015

If you try to run knitr with pdfcrop installed but don't have ghostscript you get the error:
!!! Error: Ghostscript exited with error code 127!
from pdfcrop.

If you run pdfcrop in debug mode you find that this simply means it can't find ghostscript.

If pdfcrop has a dependency on ghostscript then it should be checked that it exists before running it and have a warning that it doesn't exist if it doesn't.

@yihui
Copy link
Owner

yihui commented Feb 16, 2015

Thanks for the report, but I'm afraid this would mean too much responsibility on my side. The pdfcrop homepage has stated anyway that it depends on Ghostscript: http://pdfcrop.sourceforge.net and I have never received a report on this issue before, so I assume it is a rare issue.

@yihui yihui closed this as completed Feb 16, 2015
@yihui yihui added this to the v1.10 milestone Feb 16, 2015
@skanskan
Copy link

skanskan commented Oct 7, 2017

I have the same error when compiling some latex code with pdflatex.

\documentclass[border=3pt, x11names]{standalone}%
\usepackage{pst-node}
\usepackage{auto-pst-pdf}
\begin{document}
\sffamily
\psset{algebraic, yunit = -1, arrows=->, arrowinset=0.12, linecolor=SteelBlue3, fillcolor=SlateGray3!60, nodesepB=1pt}
\begin{pspicture*}
  \foreach \X[count=\I] in {A, B, C, D, E} {\Cnodeput[linecolor=SteelBlue4, fillstyle=solid]{0}(\I, \I){\X}{\X}}
  \foreach \X/\Y in{A/B, B/C, C/D, D/E}{\ncline{\X}{\Y}}
  \ncarc[arcangle=-25]{A}{D}
\end{pspicture*}
\end{document}

@jtbayly
Copy link

jtbayly commented Sep 8, 2020

I don't know if this is a problem, but I'm seeing this error when building a book with bookdown using the default demo book with one additional line:

```{r, echo=FALSE, fig.align='center', out.width='50%'}
    knitr::include_graphics("images/am_I_crazy.png")
    ```

Worth noting that the build doesn't fail so far as I can tell. I just happened to notice that error in the Travis CI log.

@yihui
Copy link
Owner

yihui commented Sep 8, 2020

@jtbayly That's too little information for us to tell anything. Please read and follow the issue guide exactly to provide all the required information. Thanks!

@jtbayly
Copy link

jtbayly commented Sep 8, 2020

I’m sorry, but I don’t have any idea what versions of things are used in the Travis CI build process (except Pandoc, which is specified in the demo book .travis.yml file as pandoc_version: 1.19.2.1). I also don’t know how to get an xfun session out of the Travis virtual machine.

I’m just reporting it as a courtesy. If you care about it or think it’s worth looking into it, you can build the demo book with Travis CI, after adding a sub-directory with an image and that line above.

Sorry I can’t provide more in this instance without more instruction.

@yihui
Copy link
Owner

yihui commented Sep 8, 2020

No worries. Could you at least provide a link to the Travis log (or better, your Github repo as a reproducible example)?

Without further information, it's really hard to guess. There was a bug related to this before knitr 1.28, but I have fixed it earlier this year: https://github.com/yihui/knitr/releases/tag/v1.28 If you are using the latest version of knitr, I cannot think of a reason why this problem can still occur.

@jtbayly
Copy link

jtbayly commented Sep 8, 2020

This particular branch seems to build just fine, but has the error in the Travis CI log.

Here's the Travis log.

Perhaps the Travis CI builds aren't using knitr 1.28 yet?

Edit: I managed to figure out how to output the xfun session info into the book, and here's what I got:

## R version 4.0.2 (2020-06-22) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 16.04.6 LTS  Locale:   LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C                 LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8       LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8      LC_PAPER=en_US.UTF-8       LC_NAME=C                    LC_ADDRESS=C               LC_TELEPHONE=C               LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C         Package version:   evaluate_0.14   glue_1.4.2      graphics_4.0.2  grDevices_4.0.2   highr_0.8       knitr_1.29      magrittr_1.5    markdown_1.1      methods_4.0.2   mime_0.9        stats_4.0.2     stringi_1.4.6     stringr_1.4.0   tools_4.0.2     utils_4.0.2     xfun_0.16         yaml_2.2.1

@yihui
Copy link
Owner

yihui commented Sep 9, 2020

From https://travis-ci.org/github/warhornmedia/bookdown-test/builds/725242542, the actual error was:

! LaTeX Error: File `../images/am_I_crazy' not found.
Error: LaTeX failed to compile bookdown-demo.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See bookdown-demo.log for more info.

That was caused by the fact that the image does not exist.

The ghostscript issue caused a warning:

In addition: Warning message:
In system2("pdfcrop", shQuote(c(x, x)), stdout = if (quiet) FALSE else "") :
  error in running command

This only means figure cropping failed: https://bookdown.org/yihui/rmarkdown-cookbook/crop-plot.html I'm not sure if you really need this feature. If you don't, you can turn it off by setting knitr::opts_chunk$set(crop = NULL).

I'm not sure what's going on with ghostscript on Travis, and I don't have time to debug it. Sorry.
You need to install ghostscript on Travis: https://github.com/warhornmedia/bookdown-test/pull/1

yihui added a commit to rstudio/bookdown-demo that referenced this issue Sep 9, 2020
yihui added a commit to rstudio/rmarkdown that referenced this issue Sep 9, 2020
…hostscript are found (yihui/knitr#954), and do not limit this feature to non-Windows platforms
@yihui
Copy link
Owner

yihui commented Sep 9, 2020

@dalupus I take back what I said in 2015. Looking at the replies above and linked issues, I feel that it is obviously a highly confusing problem to many people. Therefore I just added the check for the existence of ghostscript. I definitely owe you a "thank you" and it's probably not too late five years later :)

yihui added a commit that referenced this issue Sep 9, 2020
@jtbayly
Copy link

jtbayly commented Sep 9, 2020

I’m so sorry I sent the log with the additional error. That is definitely a separate issue that I was working on. I meant to send the data with only the Ghostscript error.

@yihui
Copy link
Owner

yihui commented Sep 9, 2020

@jtbayly No worries. I think we are all set now. You can either merge https://github.com/warhornmedia/bookdown-test/pull/1 or

remotes::install_github(c('yihui/knitr', 'rstudio/rmarkdown'))

jonathan-g added a commit to jonathan-g/rmarkdown that referenced this issue Sep 24, 2020
* rstudio_origin/master:
  fix rstudio#1905: a chunk with the class "fold-hide" should only hide itself (rstudio#1906)
  bump version after merging rstudio#1899
  lua filter -> Lua filter
  Add an argument `lua_filters` to pandoc_options() to store them in the output format object (rstudio#1899)
  recursve into the parent dir at the end
  also suppor dir input in proj_root()
  list.files() with full.names = TRUE (so the files could be read with corret paths), and pass down the `file`/`pattern` arguments in the recursion
  use our own proj_root() instead of introducing a dependency
  rename package_root() to proj_root()
  generalize the package_root() function to work with more types of projects
  Discover site generators in index.Rmd files in parent directories (rstudio#1898)
  only install pkgdown for website build (rstudio#1900)
  Generalize number sections (rstudio#1879)
  enable figure cropping in pdf_document() only when both pdfcrop and ghostscript are found (yihui/knitr#954), and do not limit this feature to non-Windows platforms
  add the citation entry for the R Markdown Cookbook
  add lua filter vignette to pkgdown website (rstudio#1894)
  close rstudio#1889: evaluate the output argument before changing working directory in pandoc_convert() (rstudio#1890)
jonathan-g added a commit to jonathan-g/rmarkdown that referenced this issue Sep 24, 2020
Merge remote-tracking branch 'rstudio_origin/master' into css-slash-fix

# By Yihui Xie (12) and others
# Via GitHub
* rstudio_origin/master: (22 commits)
  fix rstudio#1905: a chunk with the class "fold-hide" should only hide itself (rstudio#1906)
  bump version after merging rstudio#1899
  lua filter -> Lua filter
  Add an argument `lua_filters` to pandoc_options() to store them in the output format object (rstudio#1899)
  recursve into the parent dir at the end
  also suppor dir input in proj_root()
  list.files() with full.names = TRUE (so the files could be read with corret paths), and pass down the `file`/`pattern` arguments in the recursion
  use our own proj_root() instead of introducing a dependency
  rename package_root() to proj_root()
  generalize the package_root() function to work with more types of projects
  Discover site generators in index.Rmd files in parent directories (rstudio#1898)
  only install pkgdown for website build (rstudio#1900)
  Generalize number sections (rstudio#1879)
  enable figure cropping in pdf_document() only when both pdfcrop and ghostscript are found (yihui/knitr#954), and do not limit this feature to non-Windows platforms
  add the citation entry for the R Markdown Cookbook
  add lua filter vignette to pkgdown website (rstudio#1894)
  close rstudio#1889: evaluate the output argument before changing working directory in pandoc_convert() (rstudio#1890)
  tweak news
  require Pandoc >= 1.14
  xfun 0.16 is on CRAN now
  ...

# Conflicts:
#	NEWS.md
clrpackages pushed a commit to clearlinux-pkgs/R-rmarkdown that referenced this issue Oct 6, 2020
… 2.4

Christophe Dervieux (7):
      add lua filter vignette to pkgdown website (#1894)
      only install pkgdown for website build (#1900)
      Add an argument `lua_filters` to pandoc_options() to store them in the output format object (#1899)
      lua filter -> Lua filter
      bump version after merging #1899
      Export pkg_file_lua for package author to use (#1904)
      bump patch version

J.J. Allaire (1):
      Discover site generators in index.Rmd files in parent directories (#1898)

Jonathan Gilligan (2):
      Fix #1861: do not use backslashes as path-separators in CSS links (#1862)
      Add documentation about how render() sets output_format options from YAML parameters (#1907)

JooYoung Seo (1):
      support number_sections for word_document() output (#1869)

Kirill Müller (1):
      close #1889: evaluate the output argument before changing working directory in pandoc_convert() (#1890)

Yihui Xie (26):
      start the next version
      require the data-latex attribute on fenced Div's again: rstudio/rmarkdown#1779 (comment)
      fix #1815: apply the lua filters pagebreak.lua and latex-div.lua to beamer_presentation
      replace base64enc with xfun::base64_encode/decode()
      xfun 0.16 is on CRAN now
      require Pandoc >= 1.14
      tweak news
      add the citation entry for the R Markdown Cookbook
      enable figure cropping in pdf_document() only when both pdfcrop and ghostscript are found (yihui/knitr#954), and do not limit this feature to non-Windows platforms
      generalize the package_root() function to work with more types of projects
      rename package_root() to proj_root()
      use our own proj_root() instead of introducing a dependency
      list.files() with full.names = TRUE (so the files could be read with corret paths), and pass down the `file`/`pattern` arguments in the recursion
      also suppor dir input in proj_root()
      recursve into the parent dir at the end
      add news for #1878
      tweak news and docs of #1904
      system.file() will signal a similar error when length(package) != 1, so we don't need to repeat the message here (i.e., just let system.file() fail)
      make sure the rmarkdown/lua/ folder exists
      amend #1907: the @param field doesn't allow more than one paragraph, so we shouldn't add an empty line here
      fix the redirected URL
      remove the pandoc installation vignette, which is no longer useful
      fix some redirected URLs discoverd by R CMD check on win-builder
      fix some redirected URLs discovered by the CRAN incoming check (but not the check on win-builder, which is very weird...)
      enable _R_CHECK_CRAN_INCOMING_ for r-devel, to see if it could reveal potentially "problematic" URLs as CRAN currently tries to identify
      CRAN release v2.4

atusy (6):
      make metadata available before running pre_knit (#1855)
      Generalize number sections (#1879)
      fix #1905: a chunk with the class "fold-hide" should only hide itself (#1906)
      incorporate CSS styles from latest Pandoc's tempalte (#1878)
      also incorporate CSS styles from latest Pandoc's template into ioslides (#1908)
      fix #457 and fix #1864: add `template` to `output_render_files` of discover_rmd_resources() (#1865)
@github-actions
Copy link

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants