enc2utf8 issue with render_book() from bookdown

I've been writing a book with bookdown for 9 months (to be published by CRC Press).
Everything was doing just fine until yesterday, when I got the error message:

output file: ML_factor.knit.md
Error in enc2utf8(text) : argument is not a character vector

I updated all versions (RStudio, packages (rmarkdown, knitr, bookdown, htmltools)) but I'm blocked.
I've tried coming back to previous versions of the book: that does not help.
I've seen issues with this error message on the web, but no solution has worked (to date).
Thank you!

Do you have an example you're able to share ?
It would be easier to investigate.

Do you know which version of packages worked with your old book ? You could try installing previous versions of the package if one them may have cause you breaking change.

For such project in the future, you should considered to lock your environment so that changes in package Versions are controlled and you can easily reproduce in time. Look at renv for that

Hi Christophe,
& thanks for your reply! I've tried to revert to older versions of bookdown & knitr, without success.
The chapters are all processed neatly and everything stops at the end (knitting?).
It's kind of hard to produce a clean reprex in my case (I think).
I've compressed all the minimum amount of files required and uploaded them on Google Drive:
https://drive.google.com/file/d/1G6lcPBo7KNl22-mxTxfMaSE9f8hf-AbT/view?usp=sharing .
I use Yihui's krantz class for LaTeX (CRC Press standards).
I'll definitely have to check out renv.
Thanks again for your time.

Thanks for the zip file.
I see this in your index.Rmd

header-includes: 
  -   
#  - \textwidth 5.5in  
#  - \textheight 8.5in  

This creates some issues with the new way header-includes is handled in Rmarkdown. If you remove the empty one (only -) and activate the other, or remove completely the header-includes from index.Rmd.

Can you try that ?

1 Like

Yes! I removed everything and it worked.
This was very silly of me since I moved the height/width specs to the preamble.tex file.
This was really a tex related issue because I tried to run serve_book() and it went fine.
Thank you so much for taking the time to answer & sorry to have bothered you!

Glad it works!

I guess the error message could be improved if header-includes is empty... :thinking:

If your question's been answered (even by you!), would you mind choosing a solution? It helps other people see which questions still need help, or find solutions if they have similar problems. Here’s how to do it:

I opened an issue about this regression

1 Like

This is now fixed in last dev version.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.