RMarkdown code returns fatal `error:unexpected:bad allocation` and aborts session

I'm having the same issue reported in a previous post here which received no solution.

When I go to run code chunks from an RMarkdown file an error prompt stating "fatal error:unexpected:bad allocation" pops up and then I am forced to abort R.

Copying the same code into an R Script file and running code there works fine. Running code in the console also works fine. I have opened previous projects where the RMarkdown code used to run and knit, but these now also receive the same error when running code chunks. The code lines I am running are standard e.g. library(dplyr). Occasionaly, a couple of code chunks will run but then the same error occurs later on e.g. on the 3rd chunk running str(data). However, interestingly, I am able to knit the .Rmd file without an issue.

I have updated my R studio version to 2023.3.1.446, release name Cherry Blossom. This did not resolve my issue. I have also tried in R version 4.2.2. and 4.1.2 but no luck.

Any suggestions as to what might have gone wrong and how to resolve this issue?

UPDATE

After spending some time trying different solutions I believe I have resolved my problem by updating the xfun package. I have tested several code chunks from various .Rmd files and things seems to be running as normal (for now at least). It would still be very useful if someone could enlighten me as to what could have been going wrong as this was quite a worrying issue.

Thank you in advance and happy to provide any additional information.

1 Like

Following suggestions from I need help to resolve Fata error: unexpected exception: string too long - RStudio IDE - Posit Community made by HanOostdijk, here is my RProfile info.

Running file.edit(file.path("~", ".Rprofile")) # edit .Rprofile in HOME returns:

Sys.setenv(PATH = paste("C:/rtools42/usr/bin",
                        "C:/rtools42/mingw64/bin", 
                        "C:/rtools42/x86_64-w64-mingw32/include",
                        Sys.getenv("PATH"), sep = ";"))

Running file.edit(".Rprofile") # edit project specific .Rprofile returns an empty script for the current RProject.

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.