I have said this many times in several GitHub issues and it is also the very first FAQ of knitr. It is a little exaggerative and certainly not a universal rule, but it helps a lot if you could try to upgrade everything before you report a software issue. It is even more helpful if you could also install the development version of the software and see if the problem has gone. Although it sounds like a joke, @ThePracticalDev actually has a very good point:
You may replace “Changing Stuff” with “Upgrading Stuff” above.
A few notes from my personal experience just for your reference and also for my future self (not meant to be a guide):
-
R and R packages: Unless you are a developer who cares a lot about different versions of R and has to install multiple versions of R,1 do not use or configure a versioned library path for R packages. For example, when you set
R_LIBS_USER
in~/.Renviron
, do not include the version number%V
or%v
. See more info on the help page?R_LIBS
. This means all versions of R will use the same library path, e.g.,R_LIBS_USER=~/R
. This can cause you (serious) problems after you upgrade R because some old R packages can be broken (e.g. from R 3.3.x to 3.4.0), but don’t worry, the solution is simple:update.packages(ask = FALSE, checkBuilt = TRUE)
I always recommend
checkBuilt = TRUE
. It is a conservative choice, which may waste you a few more minutes to reinstall packages that actually still work well under the new version of R, but I prefer safety over time. -
Homebrew:
brew upgrade && brew cleanup
. Homebrew is one of the two most important reasons why I switched from Linux to macOS a few years ago.2 It is so awesome and convenient, and is exactly how I expect how system package manager to work: allow the community to help manage packages via GitHub pull requests. I’m seriously looking forward to Jeroen’s project on building R packages with Homebrew. This is something I have waited for long, and I think the future of Homebrew R is brighter than the CRAN binaries of R and R packages. -
LaTeX: I think everybody knows that I dislike everything about LaTeX except the PDF output.3 I dislike the installation, maintenance, syntax, and debugging process of LaTeX. Almost everything is painful on every platform.4 I’m not going to rant more, but
just point out that updating LaTeX (and LaTeX packages) could be trickier than you imagined.TinyTeX has made it much easier compared to other LaTeX distributions: just use the R functiontinytex::tlmgr_update()
, or run the command linetlmgr update --all --self
.-
For Linux users, I recommend installing TeXLive from source and either add the bin path toPATH
orsudo tlmgr path add
. Then you can enjoy (or suffer from)tlmgr
instead of waiting for years for the official repo to have a recent version of TeXLive. For macOS users, MacTeX seems to be fine. When in doubt,tlmgr update --self --all
(requiressudo
on macOS). Still in doubt? Runfmtutil-sys --all
, whatever it means (again, may requiresudo
, depending on where you installed LaTeX). -
For Windows users, updating MikTeX may require you to update both LaTeX packages and refresh the filename database (whatever it means). Go to the Start menu, find MikTeX, and click any buttons that sound like “update me” (clicking buttons and seeing what happens).
-
Personally I prefer using the latest versions of software packages, and I upgrade whenever possible (kind of obsessive), because I don’t want to run into old bugs that have been fixed. This is not necessarily a good choice or the right thing to do, and I don’t have evidence about whether newer or older versions are better or worse in general. Newer versions may have new bugs or changes that you hate. All I want to express in this post is that when you are in trouble, you may try to upgrade first.
P.S. A list of issues solved simply by updating packages:
- Leaflet tile not showing
- Forbidden control sequence found when knitting the minimal example
- Error in render_page(f) : Failed to render ‘2015-07-23-r-rmarkdown.Rmd’
- Figures not referenced with consecutive numbers
- Kable with single column data frame ends up with no
<TABLE>
tag in generated HTML new_site()
in blogdown causes error in editor- Incompatible with Pandoc v2
- DT does not show up in Shiny after last upgrade
- Blogdown Error: Couldn’t Find Function “invalidUTF8”
- DT datatable callback function not working after update
- imgur_upload fails
- Error with RMarkdown:
is_latex_output
is not an exported object from ’namespace:knitr’ - I’m trying to install hugo for the blogdown package but I get a fatal error stating that “R session Aborted, R encountered the fatal error”
- Getting failed to upload file error when reprex contains a plot
- Allow
fun
instat_summary_2d
to returndata.frame
- about the code run wrong in xaringan
- Problem rendering PDF on binder
- Invalid arguments when building PDF output with Pandoc2
- Error while knitting a LaTeX file: could not find function “as”
- blogdown本地预览与netlify部署后的显示不一致
- Incompatible with dev version of glue
- chrome_print missing text in PDF, not with Google Chrome
- Error when running serve_site(): “Error in as.vector(x, “character”): cannot coerce type ’environment’ to vector of type ‘character’”
- tinytex::install_tinytex() can not work
- How do I force knitr to delete support directory (.png files) after HTML is knitted
- PeerJ output text appears cut
- error building theme
- DT hanging with shiny/flexdashboard
- Knit error in RStudio: pandoc conversion failed with error 23. Extension ascii_identifiers is not supported for markdown
- Table links don’t work across R Markdown documents
- knit pagedown html_resume to pdf with chrome_print produces error
- Rmarkdown not knitting to pdf ==> Fatal error occurred, no output PDF file produced
- version 1.18 not knitting to PDF due to
! Undefined control sequence. l.942 \file_get:nnN {unicode-math-table.tex} {} \l__um_mathtable_tl
- The extension ascii_identifiers is not supported for markdown
- Pagedown: Not printing an element when kniting
- include_graphics() does not work
- The extension SearchPanes does not exist
- rmarkdown removes ~/.TinyTex on errors with latex rendering
with_temp_loop
is not an exported object from ’namespace:later’- Caching does not work with R-devel when cache path contains special characters (R-4.0.0)
- Error
blogdown::serve_site
academic template - object
is_R_CMD_check
not found - Booktabs in kable
- Cannot Render Files
- Rmarkdown doesn’t knit the specified document but renders the copernicus.docx file
- Error when visualizing
- markdownExtensions problem when trying to run a tutorial
- Error in xfun::normalize_path when knit RMarkdown to HTML
- DT::formatRound(-1) throws error with only one column and rownames=F
- The function xfun::isFALSE() will be deprecated in the future
- Plots showing
\begin{figure}
and\caption{"XXX"}
when knitting to pdf - How can I overcome an error in xfun when kniting an Rmarkdown?
- Error(s) in re-building vignettes:
- R markdown error when knitting any Rmd file
build_vignettes()
fails whenlitedown::html_document
has no options- Pagedown无法生成pdf简历了
-
I guess the vast majority of R users always install and use a single version of R. ↩︎
-
The other reason was that Joe bought me a nice Thunderbolt display that wouldn’t work with my Linux laptop. I tried for a long time, screwed up my system/BIOS a couple of times, and eventually gave up (and of course, blamed Joe secretly in my mind). In retrospect, I think macOS is the best choice for me as a software developer anyway, because it is easy to install Linux and Windows as virtual machines, whereas it is probably not worth installing macOS as a virtual machine in other systems. I don’t know if it is even possible without a physical Mac machine. ↩︎
-
On an irrelevant note, I love everything about Stack Overflow except the toxic attitude towards newcomers. I’ll write about this in a future post. ↩︎
-
Comparing all these kinds of pain, installing MikTeX on Windows may be the only thing that is not painful. ↩︎