rstudio / bookdown

Authoring Books and Technical Documents with R Markdown
https://pkgs.rstudio.com/bookdown/
GNU General Public License v3.0
3.79k stars 1.27k forks source link

Unable to compile textbook (and even bookdown-demo) after Rstudio update #485

Closed deanfantazzini closed 7 years ago

deanfantazzini commented 7 years ago

I am writing a textbook for my students and after the latest update to Rstudio I am no more able to compile the pdf file and I get the same error for all possible bookdown projects, included the bookdown-demo example.

More specifically, the reported error when trying to compile the basic bookdown-demo is given below:

================================================================ This is BibTeX, Version 0.99d (MiKTeX 2.9.6500 64-bit) The top-level auxiliary file: bookdown-demo.aux The style file: apalike.bst I couldn't open database file book.bib.bib ---line 50 of file bookdown-demo.aux : \bibdata{book.bib : ,packages.bib} I'm skipping whatever remains of this command I found no database files---while reading file bookdown-demo.aux Warning--I didn't find a database entry for "R-bookdown" Warning--I didn't find a database entry for "xie2015" (There were 2 error messages) ������: Failed to build the bibliography via bibtex ��������: ��������������: 1: � file.create(to[okay]) : �� ���� ������� ���� '~/Downloads/test.txt' �� ������� 'No such file or directory' 2: ���������� ������� '"bibtex" "bookdown-demo.aux"' ����� ������ 1 3: ���������� ������� '"bibtex" "bookdown-demo.aux"' ����� ������ 1 ���������� ����������� Exited with status 1.

For some reasons, it looks for the file '~/Downloads/test.txt', but I have no idea why it does so. I tried to update all R packages, the R program itself, Miktex, etc, but to no avail. I even tried to install back the older version RStudio Desktop 1.0.153, but I get the same error.

As a good risk management practice, I write my textbook both on my desktop PC and my laptop and I keep on working on my laptop where, fearing an update can block my work, I stopped any possible update.

My sessioninfo is reported below:

sessionInfo() R version 3.4.2 (2017-09-28) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows >= 8 x64 (build 9200) Matrix products: default locale: [1] LC_COLLATE=Russian_Russia.1251 LC_CTYPE=Russian_Russia.1251 LC_MONETARY=Russian_Russia.1251 LC_NUMERIC=C
[5] LC_TIME=Russian_Russia.1251
attached base packages: [1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached): [1] compiler_3.4.2 backports_1.1.1 bookdown_0.5 magrittr_1.5 rprojroot_1.2 htmltools_0.3.6 tools_3.4.2 yaml_2.1.14
[9] Rcpp_0.12.13 stringi_1.1.5 rmarkdown_1.7 knitr_1.17 stringr_1.2.0 digest_0.6.12 evaluate_0.10.1

Thanks for any comments and help.

Best regards, Dean

yihui commented 7 years ago

Sorry, this was due to a bug in the rmarkdown package that has been fixed. You can install the development version of rmarkdown via

devtools::install_github('rstudio/rmarkdown')
deanfantazzini commented 7 years ago

Problem solved: all this has to do with the latest release of pandoc 2.0 and rmarkdown: once I read the issues for rmarkdown, everything became clear. I removed the latest updated and switched back to stable previous versions:

DO NOT INSTALL rmarkdown version 1.7 or pandoc version 2.0 because they are plagued with errors. As you can see from my error above, developers "forgot" a beta testing code line.

deanfantazzini commented 7 years ago

Sorry Yihui, I just saw your comment now. I tried again to install the version from github, but I still get errors. Find below the errors with the the bookdown-demo example:

================================ This is BibTeX, Version 0.99d (MiKTeX 2.9.6500 64-bit) The top-level auxiliary file: bookdown-demo.aux The style file: apalike.bst I couldn't open database file book.bib.bib ---line 50 of file bookdown-demo.aux : \bibdata{book.bib : ,packages.bib} I'm skipping whatever remains of this command I found no database files---while reading file bookdown-demo.aux Warning--I didn't find a database entry for "R-bookdown" Warning--I didn't find a database entry for "xie2015" (There were 2 error messages) ������: Failed to build the bibliography via bibtex ��������: ��������������: 1: ���������� ������� '"bibtex" "bookdown-demo.aux"' ����� ������ 1 2: ���������� ������� '"bibtex" "bookdown-demo.aux"' ����� ������ 1 ���������� ����������� Exited with status 1.

This is why for the moment I stick to the older stable versions:

yihui commented 7 years ago

How about changing the filenames book.bib to book and packages.bib to packages in the YAML metadata of index.Rmd?

deanfantazzini commented 7 years ago

still get errors:

=========================================== This is BibTeX, Version 0.99d (MiKTeX 2.9.6500 64-bit) The top-level auxiliary file: bookdown-demo.aux The style file: apalike.bst I couldn't open database file book.bib ---line 50 of file bookdown-demo.aux : \bibdata{book : ,packages} I'm skipping whatever remains of this command I found no database files---while reading file bookdown-demo.aux Warning--I didn't find a database entry for "R-bookdown" Warning--I didn't find a database entry for "xie2015" (There were 2 error messages) ������: Failed to build the bibliography via bibtex ��������: ��������������: 1: ���������� ������� '"bibtex" "bookdown-demo.aux"' ����� ������ 1 2: ���������� ������� '"bibtex" "bookdown-demo.aux"' ����� ������ 1 ���������� �����������

Exited with status 1.

yihui commented 7 years ago

Does the file book.bib actually exist or not? https://github.com/rstudio/bookdown-demo

yihui commented 7 years ago

I just tried the bookdown-demo example on Windows, and I could not reproduce your problem.

deanfantazzini commented 7 years ago

I now changed the filenames book.bib to book and packages.bib to packages in the YAML metadata of index.Rmd, whereas the names of the files in the directory were not changes. These are the errors that I got:

====================================== pandoc-citeproc.exe: Could not find book pandoc.exe: Error running filter pandoc-citeproc Filter returned error status 1 ������: pandoc document conversion failed with error 83 ��������: ��������������: ���������� ������� '"d:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS bookdown-demo.utf8.md --to html --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output bookdown-demo.html --smart --email-obfuscation none --standalone --section-divs --table-of-contents --toc-depth 3 --template "d:\PROGRA~2\R\R-33~1.1\library\bookdown\TEMPLA~1\GITBOO~1.HTM" --highlight-style pygments --number-sections --css style.css --include-in-header "C:\Users\Dean\AppData\Local\Temp\RtmpQd1ye5\rmarkdown-str1dd85deb52ec.html" --mathjax --filter pandoc-citeproc' ����� ������ 83 ���������� ����������� Exited with status 1.

deanfantazzini commented 7 years ago

Thanks a lot for your time. I tried all possible combinations and still get errors, this is why I will stick to the previous stable configuration

rmarkdown version 1.6 pandoc version 1.17.2

Currently, I think this is the best choice and I prefer to wait till the new releases will be more stable: it is clear that there are some conflicts which are not solved yet. Thanks again.

yihui commented 7 years ago

You need development versions of rmarkdown and bookdown:

devtools::install_github(c('rstudio/rmarkdown', 'rstudio/bookdown'))
deanfantazzini commented 7 years ago

Now, everything works! Thank you!

tchevri commented 6 years ago

Hi,

Here's my chance to join all the many public thanks to XieYiHui - FeiChang GanXie Nin Xie YiHui!

Quite interesting this issue which I am facing too. Indeed, I can run the demo without problems - the references compile just fine.

Now if I keep the .tex file, I would expect that file to still compile without issues. After parsing the document, the raw latex code includes the.bib extension for the bib filename inside \bibliography{}. However, the \bibliography command adds the .bib extension - the result being the one mentioned above: .bib.bib, i.e. the .bib extension appears twice and the file is not found. .bib should not be included inside \bibliography (see this discussion for instance)

I investigated a bit further and i see that if I keep the .tex file generated by XieYiHui's bookdown package, then that .tex file cannot be compiled for the reason mentioned above. .bib is added twice and the .bib file is not found, even though when I build the book within Rstudio it compiled just fine!! As explained above, not adding the .bib extension in the yaml header is not an option as pandoc will fail. If I am not mistaken (being a noob, I could well be!), the resolution is to not add the .bib extension inside \bibliography when parsing??

Is it possible to kindly request for this to be fixed, please?

Many thanks thomas

yihui commented 6 years ago

@tchevri Why do you need the intermediate .tex file in the first place? The .bib extension problem is very ugly (https://yihui.name/tinytex/pain/), and I strongly recommend you to use TinyTeX instead of MiKTeX. However, even with TinyTeX (which can solve the .bib problem), you are still unlikely to be able to compile the .tex file unless you move it to the correct folder. I recommend you not to touch it and treat it as something "FYI" only (and read-only).

tchevri commented 6 years ago

Noted with thanks @yihui . Thank you so much for the prompt response when i am sure you have lots of other more important things to do, including eating nice YuePing (mooncakes) :-p

Let me tell you the truth... I use your template - very cool - I get all 3 formats - gitbook, html, and pdf. Works nice. But I am dreaming about also getting slides out of this, at the same time... sorry for being griddy. A bit like what can be done with beamer: \documentclass[ignorenonframetext]{beamer} %\documentclass{article} %\usepackage{beamerarticle} Your bookdown package is based on you rmarkdown package which supports beamer... hence the idea! I tried

bookdown::pdf_book:
  includes:
    in_header: preamble.tex
    after_body: mkidx.tex
  latex_engine: xelatex
  citation_package: natbib
  keep_tex: yes
bookdown::epub_book: default
beamer_presentation:
  pandoc_args: [
      "-M", "classoption=noamsthm,a4paper,blue,xcolor={table,dvipsname}"
#      "-M", "classoption=noamsthm,a4paper,blue,handout,xcolor=table"
    ]
  includes:
    in_header: beamer-header.tex
    before_body: beamer_prefix.tex
    after_body: beamer_suffix.tex
  latex_engine: xelatex
  slide_level: 3
  # toc: true
  # incremental: true
  keep_tex: true

But I am running into all sorts of problems... hence my looking at the .tex file extensively!! because it looks like bookdown::pdf does a bunch of parsing (even though the doc says it's really nothing more than rmarkdown pdf - i would like to dare to disagree). Clearly, I am too much of a beginner, unfortunately - for instance, the pandoc arg xcolor={table,dvipsname} used to work, but no longer does. I also had to add to beamer-header.tex ugly stuff like

etc...
\newtheorem*{solution}{Solution}
\let\BeginKnitrBlock\begin \let\EndKnitrBlock\end

to get the thing to compile (If I don't use environments, a lot easier, but environments are important...). I am managing to produce slides, but it's more painful than i expected, given how slick and beautiful the package is. I know it's my bad - either it's not implemented (likely, as it's not in the well done doc) or I am messing this up... but it would be nice to be able to compile the supporting slides at the same time as the book! I know you agree! You have to :-D

Many thanks thomas

tchevri commented 6 years ago

Having spent serious time through everything... I think the solution involves base_format = rmarkdown::pdf_document and changing that to beamer... but not sure how to do it and how to control where the file gets output or maybe just change the name of the produced file? Feeling bad to trouble you with this. :-( as an fyi, i tried without success...

bookdown::pdf_document2:
  base_format: rmarkdown::beamer_presentation
  pandoc_args: [
      "-M", "classoption=noamsthm,a4paper,blue,xcolor"
#      "-M", "classoption=noamsthm,a4paper,blue,handout,xcolor=table"
    ]
  includes:
    in_header: beamer-header.tex
    before_body: beamer_prefix.tex
    after_body: beamer_suffix.tex
  latex_engine: xelatex
  citation_package: natbib
  slide_level: 3
  keep_tex: yes

(pdf_document2, because I can't have 2 pdf_book):

Error in yaml::yaml.load(string, ...) : 
  Duplicate map key: 'bookdown::pdf_book'
yihui commented 6 years ago

@tchevri Don't worry about the "trouble". If I have time to reply, I'll do it, otherwise I'll quietly beg your pardon and move on with other projects/issues.

I think you were close. base_format is an argument of bookdown::pdf_book but not bookdown::pdf_document2, so:

bookdown::pdf_book:
  base_format: rmarkdown::beamer_presentation

BTW, I do plan to make some mooncakes in the next couple of days since the Mid-Autumn Festival is getting close :)

tchevri commented 6 years ago

XieXie Nin de HeZuo @yihui , very nice of you. Yup saturday is the day according to my wife! (Singaporean Chinese, but I learnt chinese on my own, reading books and writing characters and talking to people!!). I am impressed you can cook yueping, seems quite hard. I bought a bunch - they come in all sorts of flavors now - quite cool - the quality can be uneven though, but most shops let you taste. Quite pricey though...

I hope I am not getting this wrong, but having run into more problems following your suggestion and having searched like mad for solutions, I saw in many posts you ask people to post to stack overflow instead of here. Therefore, that's what I allowed myself to do.

Stackoverflow question

Of course - if you can help me further with this, I'd very much appreciate, and I hope I did the right thing to post to stackoverflow. This is all new to me and I care to not waste your time, while enjoying your very kind support. I understand you are doing me a favor here.. This said, I hope you consider this favorably, as I am willing to bet other people may want to tag slides to their book, seems a reasonable thing to do, no? many many thanks thomas.

yihui commented 6 years ago

@tchevri You did absolutely the right thing. I'll answer there.

tchevri commented 5 years ago

i allowed myself to post a follow up question... I have been struggling ever since... but did not dare asking my question. I am very worried. i hope it's not bothersome! https://stackoverflow.com/questions/56639760/bookdown-customize-the-output-filename Many thanks thomas

github-actions[bot] commented 4 years ago

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.