2

This question is very closely related to this question, however the following differences apply:

  • OS: Unix CentOS in Docker container (image is centos) with Windows host.
  • Error: Conceptually the same error, but the fix that worked on Windows does not work here and the error message is also different.

I have created a project by using template Hugo-Xmin. In RStudio, after creating the project in blogdown, it created some predefined posts, I am editing this one:

/content/post/2015-07-23-r-rmarkdown.Rmd

I modified that file by adding this snippet at the end of the file:

This is a tikz picture:

```{r, echo=FALSE, engine='tikz', out.width='90%', fig.ext=if (knitr:::is_latex_output()) 'pdf' else 'png', fig.cap='Some caption.'}
\begin{tikzpicture}[scale=.7]
\draw [fill=gray!30,very thick] (0,-1) rectangle (5,1);
\draw [very thick] (5, 0) -- (13,0);
\node [below] at (2,-1) {\large Hello};
\node [below, align=center] at (0,-1) {\large Two\\ lines};
\end{tikzpicture}
```

Failed to process the post

My working directory is the project folder, I run from there, in the R console, the command:

blogdown::build_site()

And get this:

> blogdown::build_site()
Rendering content/_index.Rmarkdown
running: bash  -c "cd ../..;
find . -not -path '*/exampleSite/*' \\( -name '*.html' -o -name '*.css' \\) | xargs wc -l"
Rendering content/post/2015-07-23-r-rmarkdown.Rmd
This is pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013)
 restricted \write18 enabled.
entering extended mode
! LaTeX Error: File `preview.sty' not found.

! Emergency stop.
<read *>

Quitting from lines 49-55 (2015-07-23-r-rmarkdown.Rmd)
Error: Failed to compile tikz2b145b766cfa.tex. See https://yihui.name/tinytex/r/#debugging for debugging tips. See tikz2b145b766cfa.log for more info.
Execution halted
Error in render_page(f) :
  Failed to render 'content/post/2015-07-23-r-rmarkdown.Rmd'

Important Please notice that I have followed the help link and added, at the beginning of the file, this snippet:

```{r, include=FALSE}
options(tinytex.verbose = TRUE)
```

The output I reported above, is the output I get when this snippet is in place.


Troubleshooting 1

By inspecting file tikz2b145b766cfa.log (as reported in the error message), I can see the following error:

This is pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013) (format=pdflatex 2019.3.18)  18 MAR 2019 21:12
entering extended mode
 restricted \write18 enabled.
 %&-line parsing enabled.
**tikz2b145b766cfa.tex
(./tikz2b145b766cfa.tex
LaTeX2e <2011/06/27>
Babel <v3.8m> and hyphenation patterns for english, dumylang, nohyphenation, ru
ssian, ukrainian, bulgarian, loaded.
(/usr/share/texlive/texmf-dist/tex/latex/base/article.cls
Document Class: article 2007/10/19 v1.4h Standard LaTeX document class
(/usr/share/texlive/texmf-dist/tex/latex/base/size10.clo
File: size10.clo 2007/10/19 v1.4h Standard LaTeX file (size option)
)
\c@part=\count79
\c@section=\count80
\c@subsection=\count81
\c@subsubsection=\count82
\c@paragraph=\count83
\c@subparagraph=\count84
\c@figure=\count85
\c@table=\count86
\abovecaptionskip=\skip41
\belowcaptionskip=\skip42
\bibindent=\dimen102
)
\@input{preview.aux}
\openout2 = `preview.aux'.

No file preview.tex.

! LaTeX Error: File `preview.sty' not found.

Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: sty)

Enter file name:
! Emergency stop.
<read *>

l.4 \usepackage
               {amsmath}^^M
Here is how much of TeX's memory you used:
 200 strings out of 494820
 2171 string characters out of 3178049
 47774 words of memory out of 3000000
 3480 multiletter control sequences out of 15000+200000
 3640 words of font info for 14 fonts, out of 3000000 for 9000
 198 hyphenation exceptions out of 8191
 23i,0n,17p,164b,36s stack positions out of 5000i,500n,10000p,200000b,50000s

!  ==> Fatal error occurred, no output PDF file produced!

It is important to know I have installed on the CentOS system a lot of packages and software:

yum install texlive*

And:

install.packages("devtools")
remotes::install_github('yihui/knitr')
install.packages(c('magick', 'pdftools'))

In R.

Troubleshooting 2

As advised, I installed: tinytex. It succeeded. After that, after running build_site(), I always got prompted for a missing library I had to install. After 30 minutes, I got this message:

> blogdown::build_site()
Rendering content/_index.Rmarkdown
running: bash  -c "cd ../..;
find . -not -path '*/exampleSite/*' \\( -name '*.html' -o -name '*.css' \\) | xargs wc -l"
Rendering content/post/2015-07-23-r-rmarkdown.Rmd
hugo: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by hugo)
hugo: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by hugo)

This one I am struggling with unfortunately as libstdc++-4.8.5-36.el7.x86_64 is already installed and I am not sure how to fix GLIBCXX_3.4.20 and GLIBCXX_3.4.21. Trying yum install on them does not work.

Andry
  • 16,172
  • 27
  • 138
  • 246
  • You need to install `wget`. See the error message `Error: 'wget' is not found but required to install TinyTeX`. – Yihui Xie Mar 19 '19 at 15:53
  • Man I am sorry for missing these things... just working on many things and flying on error messages... error messages should be short damn it :D – Andry Mar 19 '19 at 15:54
  • No worries. I understand there are too many messages, and the actual error was buried deeply. – Yihui Xie Mar 19 '19 at 15:55
  • I have succeeded and now some processing happens but then it complains about missing `magick`. But I have installed it :( I did: `install.packages('magick')` and then quit R and got back in R again and then ran build site command and got: `Error in loadNamespace(name) : there is no package called 'magick'` – Andry Mar 19 '19 at 16:11
  • But I see some errors in the installartion of `magick`.. I am investigating... – Andry Mar 19 '19 at 16:16
  • @YihuiXie: I did it and installed stuff, now I am having another problem. Please see last part of my updated question – Andry Mar 19 '19 at 21:46
  • @YihuiXie: I can see in [this page](https://travis-ci.community/t/r-with-hugo-v0-54-0-glibcxx-3-4-20-and-glibcxx-3-4-21-not-found/2365) that you fixed a similar issue with a CI tool (which is what I am trying here) by using a different distribution of Ubuntu. I am on CentOS. Have you ever tried CentOS? I would really like to avoid adopting Ubuntu. To fix this, what do I need to install? – Andry Mar 19 '19 at 21:51
  • @YihuiXie: The more I search the web the more i understand I will need to switch to Ubuntu :( RHEL supports up to 19, 20 and 21 are not included :( Can you confirm this? – Andry Mar 19 '19 at 22:03
  • 1
    I have never used CentOS, and I don't know anything about it. I only know if you use Ubuntu, make sure the version is at least `xenial`. – Yihui Xie Mar 20 '19 at 03:26
  • Ubuntu works fine. Too bad that CentOS does not work because of that issue :( – Andry Mar 21 '19 at 20:43

1 Answers1

1

I don't know why your TeX Live could not find preview.sty, but I'm pretty sure TinyTeX will work automatically:

# first make sure all your R packages are up-to-date, then
tinytex::install_tinytex()
Yihui Xie
  • 28,913
  • 23
  • 193
  • 419
  • I did it, but I just got a message with info. I installed everything latest! See updated question thanks – Andry Mar 19 '19 at 13:25
  • If you have Docker, it should be very easy to repro this. What exactly is this missing `preview.sty`? I understand it is a `.sty` file needed by Tex, where does it come from? Is there a way I can see the generated `.tex`? – Andry Mar 19 '19 at 13:42
  • `preview.sty` comes from a LaTeX package named `preview`. If you have successfully installed TinyTeX, you can find it out by `tinytex::tlmgr_search('/preview.sty')`. Well, you don't have to run this, since the installation of missing LaTeX packages is automatic with TinyTeX. – Yihui Xie Mar 19 '19 at 15:55