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: VISSIMTravelTimer2.knit.md

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.

JAB

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?

Thanks

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.

Thanks!

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

library(rmarkdown)
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/digest.so':
dlopen(/Library/Frameworks/R.framework/Versions/4.1/Resources/library/digest/libs/digest.so, 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/digest.so
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 ?

install.packages("digest")
install.packages("rmarkdown")

Thanks

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 = "https://r-lib.github.io/p/pak/dev/")

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