I have the beginning of a bookdown project, with chapter stubs that used to compile OK before. Now I am getting a completely incomprehensible error in the pandoc step.
How can I track down where/why this is occurring?
The error, Error in x[i] <- sprintf("<a href=\"%s#%s\"", filenames[which.max(lines[lines <= : ... makes no sense to me.
output file: TOGS.knit.md
"C:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS TOGS.utf8.md --to html4 --from markdown+autolink_bare_uris+tex_math_single_backslash --output TOGS.html --lua-filter "C:\R\R-3.6.3\library\bookdown\rmarkdown\lua\custom-environment.lua" --lua-filter "C:\R\R-3.6.3\library\rmarkdown\rmarkdown\lua\pagebreak.lua" --lua-filter "C:\R\R-3.6.3\library\rmarkdown\rmarkdown\lua\latex-div.lua" --metadata-file "C:\Users\friendly\AppData\Local\Temp\Rtmp2PCoKw\file22e442b5735f" --email-obfuscation none --wrap preserve --standalone --section-divs --table-of-contents --toc-depth 3 --template "C:\R\R-3.6.3\library\bookdown\templates\gitbook.html" --highlight-style pygments --number-sections --css css/style.css --css css/chapters.css --include-in-header "C:\Users\friendly\AppData\Local\Temp\Rtmp2PCoKw\rmarkdown-str22e437505210.html" --mathjax --filter "C:/Program Files/RStudio/bin/pandoc/pandoc-citeproc.exe"
Error in x[i] <- sprintf("<a href=\"%s#%s\"", filenames[which.max(lines[lines <= :
replacement has length zero
Calls: local ... <Anonymous> -> split_chapters -> restore_links -> lapply -> FUN
Execution halted
Error in gzfile(file, "rb") : cannot open the connection
Calls: <Anonymous> ... unlist -> lapply -> FUN -> <Anonymous> -> readRDS -> gzfile
In addition: Warning message:
In gzfile(file, "rb") :
cannot open compressed file 'C:\Users\friendly\AppData\Local\Temp\Rtmp251xjv\file2d9054dd5799.rds', probable reason 'No such file or directory'
Execution halted
Exited with status 1.
This error happen in the internal restore_links() function. Without the code, or generated html to debug it will be difficult for me.
Is the code available or would you be willing to share some file with me (privatly) ?
I am just unclear about this error:
Error in gzfile(file, "rb") : cannot open the connection
Calls: <Anonymous> ... unlist -> lapply -> FUN -> <Anonymous> -> readRDS -> gzfile
In addition: Warning message:
In gzfile(file, "rb") :
cannot open compressed file 'C:\Users\friendly\AppData\Local\Temp\Rtmp251xjv\file2d9054dd5799.rds', probable reason 'No such file or directory'
Execution halted
Not sure it comes for bookdown;
Difficult to look from afar.
If you are willing to debug you can step through restore_links but that won't be the clearer path:
For that you can run this to enter the debugger
debugonce("bookdown:::restore_links")
Something is not correct in the post processing for your project.
I think you got the error here because your first header in the book is an header two (##) and not an header one (#).
Is this on purpose ? If so, I need to see how to improve how to handle this case.
Bookdown require header 1 section for each part. This is according to these h1 header that the book is split by default.
You can find some hint about the splitting in here: https://bookdown.org/yihui/bookdown/html.html
If I tranform to
# Cover image {-}
it seems to render ok.
Anyway, the error message is definitely cryptic and this should be improved IMO.
It’s odd that this is the error, as I distinctly remember making this same mistake and getting a more helpful error message.
Perhaps there is something different about how h2 and h3 or h4 (which I would have been using) are handled in this case. I wouldn’t be surprised, given how the splitting works, if the latter produce better errors.
Regardless, it’s kind of irritating that the front matter must start with an h1, since often you don’t want that to be the first thing.