Problems with crashing R session

@hsbadr It looks like the linker path for the TBB isn’t in quotations, which is causing a compilation failure when there’s a space in the filepath. You can see the full command in the post above, which contains:

-LD:/Users/Carlos Zarzar/Documents/R/win-library/4.0/RcppParallel/lib/x64 -ltbb 

Which results in the error:

g++.exe: error: Zarzar/Documents/R/win-library/4.0/RcppParallel/lib/x64: No such file or directory

LDFLAGS: Quote TBB library path · hsbadr/RcppParallel@5f730a3 · GitHub should fix this. Can you test it?

remotes::install_github("hsbadr/RcppParallel@develop", force = TRUE)

Thanks Hamada!

@Carlos_Zarzar Can you restart your R session, making sure that RStan doesn’t get loaded, then use the code above to update your RcppParallel package? Then try the rstan example model again


Ok, I did the recommended. And when it comes to running the example script in the declaration of the stan model [function stan_model ()] it came back to me:

stan_model(model_name = “Morgan Mercer Flodin”, file = “Enviar forum/mod_MMF.stan”)

Error in system.file(“lib”, .Platform$r_arch, package = “RcppParallel”, :
no file found
Furthermore: Warning message:
In read.dcf(file.path(p, “DESCRIPTION”), c(“Package”, “Version”)) :
could not open the compressed file ‘D:/Users/Carlos Zarzar/Documents/R/win-library/4.0/RcppParallel/DESCRIPTION’, probable reason ‘No such file or directory’
Error in sink(type = “output”) : invalid connection

It seems that RcppParallel hasn’t been installed successfuly. Do you have rtools installed? What’s the output of utils::packageVersion("RcppParallel")?

No, I don’t have rtools installed.


Installing package into ‘D:/Users/Carlos Zarzar/Documents/R/win-library/4.0’
(as ‘lib’ is unspecified)
Warning in install.packages :
package ‘rtools’ is not available for this version of R

A version of this package for your version of R might be available elsewhere,
see the ideas at

and about RcppParallel package it was also not installed.

Error in utils::packageVersion(“RcppParallel”) :
there is no package called ‘RcppParallel’

What happens with the following command?

remotes::install_github("hsbadr/RcppParallel@develop", force = TRUE)

This should install the development version of RcppParallel, but it seems that it fails.

remotes::install_github(“hsbadr/RcppParallel@develop”, force = TRUE)

Erro: Failed to install ‘RcppParallel’ from GitHub:
(converted from notice) installation of package ‘C:/Users/CARLOS~1/AppData/Local/Temp/RtmpGezD8Y/file2d47738527d/RcppParallel_5.1.0-9000.tar.gz’ had non-zero exit status

This doesn’t explain the error (it should be printed before the message you shared), but it’s most likely missing git and/or make. So, try after installing Git for Windows from here and git2r R package:

1 Like

Ok, I installed Git from the website indicated and also installed the git2r package.
It seems to me that it was successfully installed.

Should I run the sample script to do the test?

Yes, but 1st make sure that you’ve RcppParallel v5.1.0.9000 installed:

1 Like

Thank you so much @hsbadr
We partially solved the problem. I ran my stan model again [stan_model()], it is compiling and generating the .rds file, but it still persists in the main error described at the beginning of this topic, the Crashing Session RStudio.

So we were able to solve the problem that was caused after these commands [post#15], but the initial problem of this forum still persists.

1 Like

Have you migrated from an older version of R? I don’t think this is related to Stan as it usually happens with memory and linking issues. If at least one library is linked to an older version of R (or even linking to a different version of a dependency), it can cause a segmentation fault. So, you may need to reinstall all packages, including dependencies.

this problem started after I upgraded the R program.

platform x86_64-w64-mingw32
arch x86_64
os mingw32
system x86_64, mingw32
major 4
minor 0.4
year 2021
month 02
day 15
svn rev 80002
language R
version.string R version 4.0.4 (2021-02-15)
nickname Lost Library Book

I even updated all the packages that were available to update.

And the big problem is that I try to return to previous versions and RStan does not work as before.

Updating packages isn’t enough after migration to a new R version, since the package version doesn’t change while it’s linked to a different version of R library. You may update the packages using:

update.packages(checkBuilt = TRUE, ask = FALSE)

But, still, the packages that need compilation may have to be reinstalled.

If you’d like to check this, uninstall R and all packages (remove the personal R library directory as well) and start from a clean installation.

I will do this. Including uninstalling and cleaning all files from R, RStudio as well and starting from scratch. And then I give feedback in here [the stan forum topic] ok. I just need a little time to do this. But today I give a return.

Sounds good. I think this will fix your problem. I didn’t know that this started with R upgrade, but now it makes sense to me. You’ve mixed dependencies that crash R sessions when loaded/used.