Pop-up errors after updating rstanarm and rstan

Hi,

This morning I updated the rstanarm package (through Rstudio, Windows 10). At first things appeared to work normally, but then I started getting annoying pop-up messages that read:

rsession.exe - Entry Point Not Found

The procedure entry point EXTPR_PTR could not be located in the dynamic link library C:\Users\Michael
Schrimpf\Documents\R\win-library\4.0\rstan\libs\x64\rstan.dll.

They appear at odd times, for example, when I click the save button for the script in Rstudio.

I tried reinstalling both RTools40 and rstan, following the instructions I had followed before on:


and
https://github.com/stan-dev/rstan/wiki/Installing-RStan-from-source-on-Windows,
but that didn’t solve the problem. Does it have something to do with the fact that my R library is nested under my user folder with a space in the name? (I haven’t figured out how to link to my Microsoft account without that…very annoying).

It seemed like I could still get Stan test models to run by simply hitting OK when the messages come up, but then when I tried loading past stanreg objects I had produced:

# Directory for model output:
mod_dir <- "C:/Docs/model_output"

# Set species
species <- "NAWA"

# Model Results
fit <- readRDS(file = file.path(mod_dir, paste("fit_", species, ".rds", sep = "")))

it first gives me the pop-up again, in addition to these lines:

Warning: namespace ‘rstanarm’ is not available and has been replaced
by .GlobalEnv when processing object ‘<unknown>’
Warning: namespace ‘rstan’ is not available and has been replaced
by .GlobalEnv when processing object ‘<unknown>’

Then it does seem to load the object, but I can’t do anything with it. For example:

summary(fit)

Produces:

Error in if (df.r > 0) { : missing value where TRUE/FALSE needed

So, now I’m using:
Windows 10
R 4.0.0
RStudio 1.2.5042
Rstan 2.21.2
rstanarm 2.21.1

I haven’t yet tried updating R to 4.0.2 (was hoping to avoid that hassle if possible).

Thanks,
Michael

I haven’t seen this error before, but have you updated your R recently?

This thread: https://community.rstudio.com/t/rterm-exe-entry-point-not-found/6544/5 makes me think that this error occurs when a package built in one version of R is used in another.

It sounds like you’ve rebuilt Rstan, but maybe it’s an Rstan dependency?

I haven’t touched my R installation at all since I updated to 4.0 back in spring, and all of my rstan and rstanarm installations were done after that. They were working fine a couple days ago - this only started after I tried updating to the most recent 2.21 versions of the packages today.

I would not be surprised if it simply has to do with a file path somewhere that isn’t properly pointing to where it’s supposed to, but I simply don’t have the skills to diagnose the problem.

(I’m just a biologist with very limited programming experience trying to teach myself how to make the software work) ;)

I’m at a loss too. In a situation like this, since things are already kinda broken, I’d be tempted to go all in and just upgrade everything. Rstudio 1.3 is out, and given the error is happening with rsession.exe (I think that’s an Rstudio thing), that seems worth upgrading.

I realized it’s a two part question too and I missed the second part:

@jonah if a model has been saved using saveRDS with one version of rstan can it be loaded in a new version?

Sorry you’re getting these weird errors.

That does sound annoying! I haven’t seen these errors before. Very strange.

I know that’s been an issue for some RStan users, but I’m not sure if that’s the problem in this case. It could be.

I’m not sure if it would help, but I don’t actually think upgrading from 4.0 to 4.0.2 would be much of a hassle. You shouldn’t need to reinstall all packages with a minor/patch version increase. (Upgrading from 3.x to 4.x definitely was a hassle!)

Yeah, I think so. At least I don’t see why not.

These errors that @mbschrimpf is reporting are super weird though. I’ve never seen them before.

@bgoodri do you have any ideas here?

Ok, update (I think it’s progress…)

I updated Rstudio, and then attempted to install rstan and rstanarm again, same issue. But, when I removed them, and then installed from source, rstan installs and no longer gives me the pop-up windows.

Unfortunately it didn’t configure correctly, and here I think it’s definitely because of that pesky space, because of two reasons. 1) when I try a test model I get this error:

Warning message:
In system(paste(CXX, ARGS), ignore.stdout = TRUE, ignore.stderr = TRUE) :
  'C:/rtools40/usr/mingw_/bin/g++' not found

And 2) when I try to install rstanarm it fails with this error message:

"C:/rtools40/mingw64/bin/"g++ -m64 -std=c++1y -std=gnu++14 -I"C:/PROGRA~1/R/R-40~1.0/include" -DNDEBUG -I"../inst/include" -I"C:/Users/Michael Schrimpf/Documents/R/win-library/4.0/StanHeaders/include/src" -DBOOST_DISABLE_ASSERTS -DEIGEN_NO_DEBUG -I'C:/Users/Michael Schrimpf/Documents/R/win-library/4.0/StanHeaders/include' -I'C:/Users/Michael Schrimpf/Documents/R/win-library/4.0/rstan/include' -I'C:/Users/Michael Schrimpf/Documents/R/win-library/4.0/BH/include' -I'C:/Users/Michael Schrimpf/Documents/R/win-library/4.0/Rcpp/include' -I'C:/Users/Michael Schrimpf/Documents/R/win-library/4.0/RcppEigen/include' -I'C:/Users/Michael Schrimpf/Documents/R/win-library/4.0/RcppParallel/include'     `"C:/PROGRA~1/R/R-40~1.0/bin/x64/Rscript" -e "RcppParallel::CxxFlags()"` `"C:/PROGRA~1/R/R-40~1.0/bin/x64/Rscript" -e "StanHeaders:::CxxFlags()"`   -O3 -march=corei7 -mtune=corei7 -c stan_files/continuous.cc -o stan_files/continuous.o
g++.exe: error: Schrimpf/Documents/R/win-library/4.0/RcppParallel/include": No such file or directory
make: *** [C:/PROGRA~1/R/R-40~1.0/etc/x64/Makeconf:227: stan_files/continuous.o] Error 1
rm stan_files/continuous.cc
ERROR: compilation failed for package 'rstanarm'
* removing 'C:/Users/Michael Schrimpf/Documents/R/win-library/4.0/rstanarm'
Warning in install.packages :
  installation of package ‘rstanarm’ had non-zero exit status

The line with the g++ error obviously only includes the file path after the space.

My Makevars file was created with the code on this page:
https://github.com/stan-dev/rstan/wiki/Installing-RStan-from-source-on-Windows

and the path that it creates is coded as:

> dotR
[1] "C:\\Users\\Michael Schrimpf\\Documents/.R"

Should I make any edits to Makevars before installing rstan, perhaps?

My next idea is to simply reconfigure R to store packages in a different directory, directly on the C drive…which is probably going to have to be a long-term solution for other things as well. I know that’s possible, I just haven’t yet learned how to make Rstudio recognize that path permanently so that I can easily install and load packages without the need to constantly paste in the alternate library path.

-Michael

I think this warning is actually safe to ignore.

This I’m not sure about. It does look like the problem could be the space in the path (I think that issue affects any R package installed from source that requires compilation with RTools).

Yeah should be possible, but I don’t know the best way to do that on Windows. @bgoodri @bbbales2 or @rok_cesnovar Do you know how to do this on Windows?

1 Like

Excellent (in a way, at least the weird warning messages went away)!

Yeah moving your install should get rid of the spaces error: Workarounds for current Rstan Windows issues

Hopefully that’s it!

2 Likes

The spaces in path to the R package library is technically an Rstan issue, that can probably be fixed on our end with some quotations in the right places (this is an assumption).

Though I think having the R package library in a path without spaces is in general a good idea, as many packages struggle with it, based on my experience in the past.

@mbschrimpf there are a few guides on moving the library in the link @bbbales2 posted. Others I found useful: https://www.accelebrate.com/library/how-to-articles/r-rstudio-library
https://www.youtube.com/watch?v=2CYKuj8SEPA

Having RTools in a path with spaces is an R issue that the R devs have to address.

1 Like

Oh that’s good to know. I thought this was an issue more generally, but if other R packages work with spaces in the path to the library then RStan should too. @bgoodri do you know how to do this in RStan so we can avoid people getting this error going forward?

Just for the record, today I removed my version of R (which was 4.0.0) and installed version 4.0.2, along with Rstudio and my package library directly on the C drive, avoiding the spaces used by both my user folder and “Program Files”. I also reinstalled rtools40, just to be safe.

I was able to install Rstan from source, and rstanarm from CRAN via the Rstudio UI (I tried installing rstanarm from source first, but it failed for some reason. I didn’t take the time to look into it further when it worked the other way).

Both Rstan and rstanarm now run correctly.

I’m not exactly sure which of my remedies fixed the ultimate problem, but it works now…so I’m happy with that!

Thanks for all of your help :)

2 Likes