Recent Upgrade causes knit not to work.

I recently upgraded R to 4.0.5 and Rstudio to Version 1.4.1106.
When I run *.rmd files that executed fine previously they work fine when I execute them within Rstudio chunk by chunk. However, when I try to knit them to an html file I get the following error:

output file:

Error: 'set_envvar' is not an exported object from 'namespace:xfun'
Execution halted.

I have tried to delete the rdata file. and also set any write statements to use the full rather than relative paths.
Nothing seems to work, and the knit fails for all projects that I have previously stored.

What can I do to fix this?
Also, where is the above output *.md file stored.


Did you try updating the package version ? It seems updating R and RStudio have created a mismatch between version and your knitr or rmarkdown version needs some newer xfun

Can you update xfun, knitr and rmarkdown and see how it goes ? it should fix this.

Keeps me updated.

Hi, I'm having the same issue - recently updated R and RStudio to versions 4.1.0 and 1.4.1106 respectively, and updated all packages (including xfun, knitr and rmarkdown). I can't knit .rmd files to pdf or html anymore. I am getting this error message

sh: rmarkdown::render: command not found
Warning message:
In system(paste0("rmarkdown::render '", input, "'")) :
error in running command

Please do you have any advice how to fix this?


This is a weird issue that is happening recently. See

We don't really know how to reproduce and what triggers it.

Last hint on this was something related to a .libPaths() were packages are stored. Is your library local or shared on a network ?

Please report in the issue above with useful info you have so that we can try fix this definitely.


Thank you. I have my R packages in a local library. I copied all my packages across from the past R library folder, and updated them all to their most recent versions. I'll look at the thread you have linked, hopefully it might have a solution!

We don't have obvious solution yet. The error you get is throw by RStudio IDE and it only happens if rmarkdown package was not found by RStudio IDE (meaning rmarkdown::render() is not seen as a valid R function )

Do you think of something that would cause RStudio IDE to not found your library ?
Can you do library(rmarkdown) with success in the console ? What is your lib path .libPaths() ?

Actually I just tried that, and although I can see rmarkdown in the library, I get this error

Error: package or namespace load failed for ‘rmarkdown’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/Library/Frameworks/R.framework/Versions/4.1/Resources/library/digest/libs/':
dlopen(/Library/Frameworks/R.framework/Versions/4.1/Resources/library/digest/libs/, 6): Library not loaded: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libR.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/4.1/Resources/library/digest/libs/
Reason: image not found

PS > .libPaths()
[1] "/Library/Frameworks/R.framework/Versions/4.1/Resources/library"

So that is why you get the error I believe, because rmarkdown is not correctly installed.

Can you reinstall digest, then rmarkdown ?



digest is corrupt?

Error: package or namespace load failed for ‘rmarkdown’ in get(Info[i, 1], envir = env):
lazy-load database '/Library/Frameworks/R.framework/Versions/4.1/Resources/library/digest/R/digest.rdb' is corrupt
In addition: Warning message:
In get(Info[i, 1], envir = env) : internal error -3 in R_decompress1

Yes it seems. Did you reinstall it ? Did that went well ?

Yes, I installed them both, and that seemed fine, but library(digest) or library(markdown) gives that error about digest being corrupt...

:thinking: digest installation is not going well. You should close everything R related. Then open R console and re try installing digest. Only this one. Then look at the installation messages to see if everything is fine. Then try library(digest) to see if it is loaded.

It is required by rmarkdown to work so you need to have this package installed.

I am not on Mac, so I don't know if there is anything to watch out specifically for this package

OK - some things are starting to work now - I had also to install htmltools, magrittr and jsonlite and then rmarkdown again to get the default .rmd in Rstudio to knit to a pdf and html document.

Also, not specifically an rmarkdown issue, but it looks as though I'll need to install various dependencies for other packages to work too.

Thanks for your help !

It is possible that you library got corrupted. This happened to me in the past.
You need to reinstall everything, or try to identify the faulty packages (using a for loop to load package and catch error for example) and reinstall those.

You issue helped me understand more what happens so thanks!

I've been working through reinstallations which has been a lengthy process - the only way it seemed to work was to quit R between every installation to get packages to reinstall correctly. Everything I need is working now though so thanks again

You may be interested in using pak

This is a great R package for packages quick and safe package installation.

Install from here and use pak::pak()

install.packages("pak", repos = "")

One of the feature is to install in its own process, detect already loaded packages and more.

I had this same issue with the default .rmd file in RStudio failing to knit after updating the rmarkdown package. Following the above advice to reinstall both digest and rmarkdown solved the issue for me. Thanks!

1 Like

I have a similar issue--running on Windows 10. I have removed and reinstalled both digest and rmarkdown to no avail. When I hit knit I get told "Rendering R Markdown requires an updated version of the rmarkdown package." (I currently have version 2.8. I am running RStudio 1.4.1717 and R 4.0.5.)

The install fails with

Error in namespaceExport(ns, exports) : 
  undefined exports: Rcmd, Rscript, Rscript_call, as_strict_list, base64_decode, base64_encode, base64_uri, bg_process, broken_packages, bump_version, cache_rds, check_old_package, check_package_name, compare_Rcheck, del_empty_dir, dir_create, dir_exists, do_once, download_file, embed_dir, embed_file, embed_files, exit_call, file_exists, file_ext, file_string, format_bytes, from_root, github_releases, grep_sub, gsub_dir, gsub_ext, gsub_file, gsub_files, in_dir, install_dir, install_github, is_CRAN_incoming, is_R_CMD_check, is_abs_path, is_ascii, is_linux, is_macos, is_rel_path, is_sub_path, is_unix, is_web_path, is_windows, json_vector, loadable, magic_path, mark_dirs, msg_cat, n2w, native_encode, news2md, normalize_path, numbers_to_words, optipng, parse_only, pkg_attach, pkg_attach2, pkg_available, pkg_load, pkg_load2, proc_kill, process_file, proj_root, prose_index, protect_math, raw_string, read_bin, read_utf8, relative_path, rename_seq, retry, rev_check, root_rules, rstudio
Calls: <Anonymous> ... namespaceImportFrom -> asNamespace -> loadNamespace -> namespaceExport
Execution halted
ERROR: lazy loading failed for package 'rmarkdown'
* removing 'C:/Users/Dick/Documents/R/win-library/4.0/rmarkdown'
Warning in install.packages :
  installation of package ‘rmarkdown’ had non-zero exit status

Hi @startz

Can you check you have the package xfun installed ?

You need this package in its last version. It should have been installed with Rmarkdown but it seems it is not correctly are functions are not correctly found.

Just try to reinstall xfun then rmarkdown