rstan icon indicating copy to clipboard operation
rstan copied to clipboard

rstan for R 4.2.0 and Rtools 4.2

Open ploutal7 opened this issue 3 years ago • 15 comments

Summary:

Can't install package rstan using R 4.2.0 and Rtools 4.2 on Windows,

Description:

Tried several different installations, including from source and also several binaries from different repositories. The installation from source has nonzero exit status, and the binary installations cause the R gui to shut down, without warning, when I run the command library(rstan).

Here's my system info: sysname release version machine "Windows" "10 x64" "build 19044" "x86-64"

I'm pretty sure this isn't a bug; I'm guessing developers haven't updated rstan for the newest R Windows releases. I'm wondering when they'll get to this--please let me know whenever you find time. Thanks.

ploutal7 avatar May 02 '22 03:05 ploutal7

Installing the latest dev version (2.26.11) solved a similiar issue for me!

# run the next line if you already have rstan installed
remove.packages(c("StanHeaders", "rstan"))

install.packages("rstan", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))

Cheers

jgman86 avatar May 05 '22 14:05 jgman86

Unfortunately, using the development version didn't change the behavior. R still shuts down, without warning, when I try to load "rstan" via library(rstan). I ran the remove.packages command shown above first, just to make sure an old installation wasn't messing things up.

Paul Louisell

On Thu, May 5, 2022 at 10:52 AM Jan Göttmann @.***> wrote:

Installing the latest dev Version solved a similiar Issue for me!

run the next line if you already have rstan installed

remove.packages(c("StanHeaders", "rstan"))

install.packages("rstan", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))

Cheers

— Reply to this email directly, view it on GitHub https://github.com/stan-dev/rstan/issues/1007#issuecomment-1118652710, or unsubscribe https://github.com/notifications/unsubscribe-auth/AY7BAO3E7XTGVE4VFQXO6T3VIPOENANCNFSM5U223DZA . You are receiving this because you authored the thread.Message ID: @.***>

ploutal7 avatar May 07 '22 05:05 ploutal7

rstan and brms cause R 4.2.0 and RStudio session abort. Even re-installation of rstan and brmscause the error.

enter image description here

enter image description here

sessionInfo()
R version 4.2.0 (2022-04-22 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 22000)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.utf8 
[2] LC_CTYPE=English_United States.utf8   
[3] LC_MONETARY=English_United States.utf8
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.utf8    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods  
[7] base     

loaded via a namespace (and not attached):
[1] compiler_4.2.0 tools_4.2.0    pacman_0.5.1 

myaseen208 avatar May 09 '22 14:05 myaseen208

grafik

I can't replicate this Issue, mine is running fine under following Session Properties:

R version 4.2.0 (2022-04-22 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19044)

Matrix products: default

locale:
[1] LC_COLLATE=German_Germany.utf8  
LC_CTYPE=German_Germany.utf8    
LC_MONETARY=German_Germany.utf8 LC_NUMERIC=C                   
LC_TIME=German_Germany.utf8    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] brms_2.17.0     Rcpp_1.0.8.3    truncnorm_1.0-8 devtools_2.4.3  usethis_2.1.5

Are you on the Windows Insider Program by Chance?

jgman86 avatar May 09 '22 14:05 jgman86

Here's an R session, with session info at the top. R closes, without warning, after invoking the example function at bottom. When I try to load rstan via library(rstan), instead of using the example function, R again closes without warning. See more comments below this first R session.

sessionInfo() R version 4.2.0 (2022-04-22 ucrt) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19044)

Matrix products: default

locale: [1] LC_COLLATE=English_United States.utf8 LC_CTYPE=English_United States.utf8 [3] LC_MONETARY=English_United States.utf8 LC_NUMERIC=C

[5] LC_TIME=English_United States.utf8

attached base packages: [1] stats graphics grDevices datasets utils methods base

loaded via a namespace (and not attached): [1] compiler_4.2.0 tools_4.2.0

remove.packages(c("StanHeaders", "rstan")) Removing packages from ‘C:/R_Libraries’ (as ‘lib’ is unspecified) install.packages("rstan", repos = c("https://mc-stan.org/r-packages/", getOption("repos")), dependencies=T) Installing package into ‘C:/R_Libraries’ (as ‘lib’ is unspecified) also installing the dependency ‘StanHeaders’

trying URL ' https://mc-stan.org/r-packages/bin/windows/contrib/4.2/StanHeaders_2.26.11.zip ' Content type 'application/zip' length 3198986 bytes (3.1 MB) downloaded 3.1 MB

trying URL ' https://mc-stan.org/r-packages/bin/windows/contrib/4.2/rstan_2.26.11.zip' Content type 'application/zip' length 2341210 bytes (2.2 MB) downloaded 2.2 MB

package ‘StanHeaders’ successfully unpacked and MD5 sums checked package ‘rstan’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in C:\Open Source\Stat Software\TMP\RtmpO8LWHs\downloaded_packages

example(stan_model, package = "rstan", run.dontrun = TRUE) # R gui closes without warning.

Compiling rstan from source yields this (I've removed the intermediate lines--the only error I could find was at the bottom as rstan was being tested for loading, but I didn't check through each line of output):

sessionInfo() R version 4.2.0 (2022-04-22 ucrt) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19044)

Matrix products: default

locale: [1] LC_COLLATE=English_United States.utf8 LC_CTYPE=English_United States.utf8 [3] LC_MONETARY=English_United States.utf8 LC_NUMERIC=C

[5] LC_TIME=English_United States.utf8

attached base packages: [1] stats graphics grDevices datasets utils methods base

loaded via a namespace (and not attached): [1] compiler_4.2.0 tools_4.2.0

remove.packages(c("StanHeaders", "rstan")) Removing packages from ‘C:/R_Libraries’ (as ‘lib’ is unspecified)

install.packages("rstan", repos = c("https://mc-stan.org/r-packages/", getOption("repos")), dependencies=T, type="source")

... intermediate lines ...

** testing if installed package can be loaded from temporary location ERROR: loading failed

  • removing 'C:/R_Libraries/rstan'

The downloaded source packages are in ‘C:\Open Source\Stat Software\TMP\Rtmpmc8bZv\downloaded_packages’ Warning message: In install.packages("rstan", repos = c("https://mc-stan.org/r-packages/", : installation of package ‘rstan’ had non-zero exit status

On Mon, May 9, 2022 at 10:29 AM Jan Göttmann @.***> wrote:

[image: grafik] https://user-images.githubusercontent.com/81758548/167431759-5a9027aa-d88d-4629-8544-ce6ad08d8444.png

I can't replicate this Issue, mine is running fine under following Session Properties:

R version 4.2.0 (2022-04-22 ucrt) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19044)

Matrix products: default

locale: [1] LC_COLLATE=German_Germany.utf8 LC_CTYPE=German_Germany.utf8 LC_MONETARY=German_Germany.utf8 LC_NUMERIC=C LC_TIME=German_Germany.utf8

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] brms_2.17.0 Rcpp_1.0.8.3 truncnorm_1.0-8 devtools_2.4.3 usethis_2.1.5

— Reply to this email directly, view it on GitHub https://github.com/stan-dev/rstan/issues/1007#issuecomment-1121179384, or unsubscribe https://github.com/notifications/unsubscribe-auth/AY7BAO7L7KR7QLYWDH5M2GTVJEONRANCNFSM5U223DZA . You are receiving this because you authored the thread.Message ID: @.***>

ploutal7 avatar May 10 '22 02:05 ploutal7

Additional info, although I don't know how helpful it will be. I opened the Windows event viewer to see what info showed, and an instance of the Rgui crash shows below:

Faulting application name: Rgui.exe, version: 4.20.16693.0, time stamp: 0x62629b8f Faulting module name: ntdll.dll, version: 10.0.19041.1682, time stamp: 0x7b5414ec Exception code: 0xc0000005 Fault offset: 0x00000000000a6c3b Faulting process id: 0x3154 Faulting application start time: 0x01d864145cd8de85 Faulting application path: C:\Program Files\R\R-4.2.0\bin\x64\Rgui.exe Faulting module path: C:\WINDOWS\SYSTEM32\ntdll.dll

It looks like it has something to do with a dll in the SYSTEM32 folder.

On Mon, May 9, 2022 at 10:40 PM Paul @.***> wrote:

Here's an R session, with session info at the top. R closes, without warning, after invoking the example function at bottom. When I try to load rstan via library(rstan), instead of using the example function, R again closes without warning. See more comments below this first R session.

sessionInfo() R version 4.2.0 (2022-04-22 ucrt) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19044)

Matrix products: default

locale: [1] LC_COLLATE=English_United States.utf8 LC_CTYPE=English_United States.utf8 [3] LC_MONETARY=English_United States.utf8 LC_NUMERIC=C

[5] LC_TIME=English_United States.utf8

attached base packages: [1] stats graphics grDevices datasets utils methods base

loaded via a namespace (and not attached): [1] compiler_4.2.0 tools_4.2.0

remove.packages(c("StanHeaders", "rstan")) Removing packages from ‘C:/R_Libraries’ (as ‘lib’ is unspecified) install.packages("rstan", repos = c("https://mc-stan.org/r-packages/", getOption("repos")), dependencies=T) Installing package into ‘C:/R_Libraries’ (as ‘lib’ is unspecified) also installing the dependency ‘StanHeaders’

trying URL ' https://mc-stan.org/r-packages/bin/windows/contrib/4.2/StanHeaders_2.26.11.zip ' Content type 'application/zip' length 3198986 bytes (3.1 MB) downloaded 3.1 MB

trying URL ' https://mc-stan.org/r-packages/bin/windows/contrib/4.2/rstan_2.26.11.zip' Content type 'application/zip' length 2341210 bytes (2.2 MB) downloaded 2.2 MB

package ‘StanHeaders’ successfully unpacked and MD5 sums checked package ‘rstan’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in C:\Open Source\Stat Software\TMP\RtmpO8LWHs\downloaded_packages

example(stan_model, package = "rstan", run.dontrun = TRUE) # R gui closes without warning.

Compiling rstan from source yields this (I've removed the intermediate lines--the only error I could find was at the bottom as rstan was being tested for loading, but I didn't check through each line of output):

sessionInfo() R version 4.2.0 (2022-04-22 ucrt) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19044)

Matrix products: default

locale: [1] LC_COLLATE=English_United States.utf8 LC_CTYPE=English_United States.utf8 [3] LC_MONETARY=English_United States.utf8 LC_NUMERIC=C

[5] LC_TIME=English_United States.utf8

attached base packages: [1] stats graphics grDevices datasets utils methods base

loaded via a namespace (and not attached): [1] compiler_4.2.0 tools_4.2.0

remove.packages(c("StanHeaders", "rstan")) Removing packages from ‘C:/R_Libraries’ (as ‘lib’ is unspecified)

install.packages("rstan", repos = c("https://mc-stan.org/r-packages/", getOption("repos")), dependencies=T, type="source")

... intermediate lines ...

** testing if installed package can be loaded from temporary location ERROR: loading failed

  • removing 'C:/R_Libraries/rstan'

The downloaded source packages are in ‘C:\Open Source\Stat Software\TMP\Rtmpmc8bZv\downloaded_packages’ Warning message: In install.packages("rstan", repos = c("https://mc-stan.org/r-packages/", : installation of package ‘rstan’ had non-zero exit status

On Mon, May 9, 2022 at 10:29 AM Jan Göttmann @.***> wrote:

[image: grafik] https://user-images.githubusercontent.com/81758548/167431759-5a9027aa-d88d-4629-8544-ce6ad08d8444.png

I can't replicate this Issue, mine is running fine under following Session Properties:

R version 4.2.0 (2022-04-22 ucrt) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19044)

Matrix products: default

locale: [1] LC_COLLATE=German_Germany.utf8 LC_CTYPE=German_Germany.utf8 LC_MONETARY=German_Germany.utf8 LC_NUMERIC=C LC_TIME=German_Germany.utf8

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] brms_2.17.0 Rcpp_1.0.8.3 truncnorm_1.0-8 devtools_2.4.3 usethis_2.1.5

— Reply to this email directly, view it on GitHub https://github.com/stan-dev/rstan/issues/1007#issuecomment-1121179384, or unsubscribe https://github.com/notifications/unsubscribe-auth/AY7BAO7L7KR7QLYWDH5M2GTVJEONRANCNFSM5U223DZA . You are receiving this because you authored the thread.Message ID: @.***>

ploutal7 avatar May 10 '22 04:05 ploutal7

maybe you can try lower R version like 4.0.2 or 4.0.5, and lower Rtool40, i found R 4.0.2 and Rtool40 can match perfectly

ChenghuFeng avatar May 18 '22 01:05 ChenghuFeng

Yes, I had *rstan *working with R version 4.1.3 and RTools4.0.1--I can always reinstall these if necessary. I know it must be somewhat hard on STAN developers because the Windows version of R updates so frequently, but I'm wondering when *rstan *will work with RTools4.2.

On Tue, May 17, 2022 at 9:03 PM ChenghuFeng @.***> wrote:

maybe you can try lower R version like 4.0.2 or 4.0.5, and lower Rtool40, i found R 4.0.2 and Rtool40 can match perfectly

— Reply to this email directly, view it on GitHub https://github.com/stan-dev/rstan/issues/1007#issuecomment-1129461316, or unsubscribe https://github.com/notifications/unsubscribe-auth/AY7BAO2PT5EAB2PCMOQFGE3VKQ6UVANCNFSM5U223DZA . You are receiving this because you authored the thread.Message ID: @.***>

ploutal7 avatar May 18 '22 06:05 ploutal7

I had this same issue, whether I used RStudio or just plain R. Attempting to load rstan with library(rstan) caused my R session to immediately crash after I updated R to 4.2.0.

I don't understand why, but the issue was resolved for me by resinstalling rstan and some of its dependencies.

install.packages(c("BH", "StanHeaders", "Rcpp", "RcppEigen", "RcppParallel",
                             "inline", "loo", "pkgbuild", "rstan"))

bschneidr avatar May 18 '22 13:05 bschneidr

Thanks @bschneidr for your comment. Reinstalling rstan along with its some dependencies as you given also works for me. Thanks

install.packages(c("BH", "StanHeaders", "Rcpp", "RcppEigen", "RcppParallel", "inline", "loo", "pkgbuild", "rstan"))

myaseen208 avatar May 18 '22 13:05 myaseen208

So I tried what Ben Schneider suggested; specifically, I did this:

remove.packages(c("BH", "StanHeaders", "Rcpp", "RcppEigen", "RcppParallel", "inline", "loo", "pkgbuild", "rstan"))

And then I restarted R 4.2.0 and did this:

install.packages(c("BH", "StanHeaders", "Rcpp", "RcppEigen", "RcppParallel", "inline", "loo", "pkgbuild", "rstan"), dependencies=T) example(stan_model, package = "rstan", run.dontrun = TRUE)

The good news is R didn't crash. The bad news is I got a lot of screen output with this final error:

Compilation ERROR, function(s)/method(s) not created! Error in compileCode(f, code, language = language, verbose = verbose) : C:\rtools42\x86_64-w64-mingw32.static.posix\bin/ld.exe: file1b9c1bde7373.o:file1b9c1bde7373.cpp:(.text$_ZN3tbb8internal26task_scheduler_observer_v3D0Ev[_ZN3tbb8internal26task_scheduler_observer_v3D0Ev]+0x1d): undefined reference to tbb::internal::task_scheduler_observer_v3::observe(bool)'C:\rtools42\x86_64-w64-mingw32.static.posix\bin/ld.exe: file1b9c1bde7373.o:file1b9c1bde7373.cpp:(.text$_ZN3tbb10interface623task_scheduler_observerD1Ev[_ZN3tbb10interface623task_scheduler_observerD1Ev]+0x1d): undefined reference to tbb::internal::task_scheduler_observer_v3::observe(bool)'C:\rtools42\x86_64-w64-mingw32.static.posix\bin/ld.exe: file1b9c1bde7373.o:file1b9c1bde7373.cpp:(.text$_ZN3tbb10interface623task_scheduler_observerD1Ev[_ZN3tbb10interface623task_scheduler_observerD1Ev]+0x3a): undefined reference to `tbb::internal::task_scheduler_observer_v3::observe(bool)'C:\rtools42\x86_64-w64-mingw32.static.posix\bin/ld.exe: file1b9c1bde7373.o:file1b9c1bde7373.cpp:(.text$_ZN3tbb10interface

Loading *rstan *via library(rstan) no longer causes a crash, but when I try to run the Eight Schools example, I get this:

fit <- stan(file = 'schools.stan', data = schools_dat) hash mismatch so recompiling; make sure Stan code ends with a blank line make cmd is make -f "C:/PROGRA~1/R/R-42~1.0/etc/x64/Makeconf" -f "C:/PROGRA~1/R/R-42~1.0/share/make/winshlib.mk" -f "C:\Users\louta\Documents/.R/Makevars.win" CXX='$(CXX14) $(CXX14STD)' CXXFLAGS='$(CXX14FLAGS)' CXXPICFLAGS='$(CXX14PICFLAGS)' SHLIB_LDFLAGS='$(SHLIB_CXX14LDFLAGS)' SHLIB_LD='$(SHLIB_CXX14LD)' SHLIB="file1b9c545430b5.dll" WIN=64 TCLBIN= OBJECTS="file1b9c545430b5.o"

make would use if test "zfile1b9c545430b5.o" != "z"; then
if test -e "file1b9c545430b5-win.def"; then
echo g++ -shared -s -static-libgcc -o file1b9c545430b5.dll file1b9c545430b5-win.def file1b9c545430b5.o -L"C:/rtools42/x86_64-w64-mingw32.static.posix/lib/x64" -L"C:/rtools42/x86_64-w64-mingw32.static.posix/lib" -L"C:/PROGRA~1/R/R-42~1.0/bin/x64" -lR ;
g++ -shared -s -static-libgcc -o file1b9c545430b5.dll file1b9c545430b5-win.def file1b9c545430b5.o -L"C:/rtools42/x86_64-w64-mingw32.static.posix/lib/x64" -L"C:/rtools42/x86_64-w64-mingw32.static.posix/lib" -L"C:/PROGRA~1/R/R-42~1.0/bin/x64" -lR ;
else
echo EXPORTS > tmp.def;
nm file1b9c545430b5.o | sed -n 's/^.* [BCDRT] / /p' | sed -e '/[.]refptr[.]/d' -e '/[.]weak[.]/d' | sed 's/[^ ][^ ]*/"&"/g' >> tmp.def;
echo g++ -shared -s -static-libgcc -o file1b9c545430b5.dll tmp.def file1b9c545430b5.o -L"C:/rtools42/x86_64-w64-mingw32.static.posix/lib/x64" -L"C:/rtools42/x86_64-w64-mingw32.static.posix/lib" -L"C:/PROGRA~1/R/R-42~1.0/bin/x64" -lR ;
g++ -shared -s -static-libgcc -o file1b9c545430b5.dll tmp.def file1b9c545430b5.o -L"C:/rtools42/x86_64-w64-mingw32.static.posix/lib/x64" -L"C:/rtools42/x86_64-w64-mingw32.static.posix/lib" -L"C:/PROGRA~1/R/R-42~1.0/bin/x64" -lR ;
rm -f tmp.def;
fi
fi Error in compileCode(f, code, language = language, verbose = verbose) : C:\rtools42\x86_64-w64-mingw32.static.posix\bin/ld.exe: file1b9c545430b5.o:file1b9c545430b5.cpp:(.text$_ZN3tbb8internal26task_scheduler_observer_v3D0Ev[_ZN3tbb8internal26task_scheduler_observer_v3D0Ev]+0x1d): undefined reference to tbb::internal::task_scheduler_observer_v3::observe(bool)'C:\rtools42\x86_64-w64-mingw32.static.posix\bin/ld.exe: file1b9c545430b5.o:file1b9c545430b5.cpp:(.text$_ZN3tbb10interface623task_scheduler_observerD1Ev[_ZN3tbb10interface623task_scheduler_observerD1Ev]+0x1d): undefined reference to tbb::internal::task_scheduler_observer_v3::observe(bool)'C:\rtools42\x86_64-w64-mingw32.static.posix\bin/ld.exe: file1b9c545430b5.o:file1b9c545430b5.cpp:(.text$_ZN3tbb10interface623task_scheduler_observerD1Ev[_ZN3tbb10interface623task_scheduler_observerD1Ev]+0x3a): undefined reference to `tbb::internal::task_scheduler_observer_v3::observe(bool)'C:\rtools42\x86_64-w64-mingw32.static.posix\bin/ld.exe: file1b9c545430b5.o:file1b9c545430b5.cpp:(.text$_ZN3tbb10interface Error in sink(type = "output") : invalid connection

On Wed, May 18, 2022 at 9:57 AM myaseen208 @.***> wrote:

Thanks @bschneidr https://github.com/bschneidr for your comment. Reinstalling rstan along with its some dependencies as you given also works for me. Thanks

install.packages(c("BH", "StanHeaders", "Rcpp", "RcppEigen", "RcppParallel", "inline", "loo", "pkgbuild", "rstan"))

— Reply to this email directly, view it on GitHub https://github.com/stan-dev/rstan/issues/1007#issuecomment-1130051243, or unsubscribe https://github.com/notifications/unsubscribe-auth/AY7BAO6G74QLZEQRCGJS6QLVKTZNHANCNFSM5U223DZA . You are receiving this because you authored the thread.Message ID: @.***>

ploutal7 avatar May 19 '22 03:05 ploutal7

Hi,

I'm using Windows 11 in Windows Insider Program and had the same issue. I managed to solve it by:

  1. Removing the following packages:
remove.packages(c("BH", "StanHeaders", "Rcpp", "RcppEigen", "RcppParallel",
                             "inline", "loo", "pkgbuild", "rstan"))
  1. Restarting R 4.2.0
  2. Following https://github.com/stan-dev/rstan/wiki/Configuring-C---Toolchain-for-Windows for R4.0. I basically just copy-pasted the code. However, I changed writeLines('PATH="${RTOOLS40_HOME}\\usr\\bin;${PATH}"', con = "~/.Renviron") to writeLines('PATH="${RTOOLS42_HOME}\\usr\\bin;${PATH}"', con = "~/.Renviron")
  3. Then,
install.packages(c("BH", "StanHeaders", "Rcpp", "RcppEigen",
"RcppParallel", "inline", "loo", "pkgbuild", "rstan"), dependencies=T)
  1. I also ran install.packages("rstan", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))

I guess the steps 4 and 5 are somewhat redundant. But configuring the C toolchain for rtools 4.2 and configuring the makevars file probably did the trick.

LeoSokolovic avatar May 21 '22 07:05 LeoSokolovic

This didn't work for me; I'd already configured the toolchain for Rtools 4.2, and modifying the PATH variable didn't change it--it only causes "C:\rtools42\usr\bin;" to repeat in the PATH.

But I finally found something that WORKED for me:

remove.packages(c("BH", "StanHeaders", "Rcpp", "RcppEigen", "RcppParallel", "inline", "loo", "pkgbuild", "rstan"))

Quit and restart R.

install.packages(c("BH", "StanHeaders", "Rcpp", "RcppEigen", "RcppParallel", "inline", "loo", "pkgbuild", "rstan"), repos = c(" https://mc-stan.org/r-packages/", getOption("repos")))

Note I'm attempting to install ALL the packages from

https://mc-stan.org/r-packages/ FIRST, not only "StanHeaders" and "rstan". This will also work with the slightly broader option "dependencies = TRUE" inserted, instead of the default "dependencies = NA".

And that was all it took--everything worked.

On Sat, May 21, 2022 at 3:47 AM LeoS @.***> wrote:

Hi,

I'm using Windows 11 in Windows Insider Program and had the same issue. I managed to solve it by:

Removing the following packages: remove.packages(c("BH", "StanHeaders", "Rcpp", "RcppEigen", "RcppParallel", "inline", "loo", "pkgbuild", "rstan")) 2.

Restarting R 4.2.0 3.

Following https://github.com/stan-dev/rstan/wiki/Configuring-C---Toolchain-for-Windows for R4.0. I basically just copy-pasted the code. However, I changed 'writeLines('PATH="${RTOOLS40_HOME}\usr\bin;${PATH}"', con = "/.Renviron")' to 'writeLines('PATH="${RTOOLS42_HOME}\usr\bin;${PATH}"', con = " /.Renviron")' 4.

Then, install.packages(c("BH", "StanHeaders", "Rcpp", "RcppEigen", "RcppParallel", "inline", "loo", "pkgbuild", "rstan"), dependencies=T) 5.

I also ran install.packages("rstan", repos = c(" https://mc-stan.org/r-packages/", getOption("repos")))

I guess the steps 4 and 5 are somewhat redundant. But configuring the C toolchain for rtools 4.2 and configuring the makevars file probably did the trick.

— Reply to this email directly, view it on GitHub https://github.com/stan-dev/rstan/issues/1007#issuecomment-1133558248, or unsubscribe https://github.com/notifications/unsubscribe-auth/AY7BAO4BUESELTAUKE2MMGLVLCIJBANCNFSM5U223DZA . You are receiving this because you authored the thread.Message ID: @.***>

ploutal7 avatar May 21 '22 12:05 ploutal7

Thanks to everyone for their help; it was a combination of Jan Göttmann's and Ben Schneider's advice that solved my problem. For anyone wondering, here's my default repository:

options("repos") $repos [1] "http://lib.stat.cmu.edu/R/CRAN/"

So at least one of the packages (*besides **StanHeaders *and rstan) in the list *BH, StanHeaders, Rcpp, RcppEigen, RcppParallel, inline, loo, pkgbuild, rstan *must have a different version at https://mc-stan.org/r-packages/ than at http://lib.stat.cmu.edu/R/CRAN/. That difference, along with possible differences between *StanHeaders *and rstan going between the repositories, was what caused my error.

On Sat, May 21, 2022 at 8:06 AM Paul @.***> wrote:

This didn't work for me; I'd already configured the toolchain for Rtools 4.2, and modifying the PATH variable didn't change it--it only causes "C:\rtools42\usr\bin;" to repeat in the PATH.

But I finally found something that WORKED for me:

remove.packages(c("BH", "StanHeaders", "Rcpp", "RcppEigen", "RcppParallel", "inline", "loo", "pkgbuild", "rstan"))

Quit and restart R.

install.packages(c("BH", "StanHeaders", "Rcpp", "RcppEigen", "RcppParallel", "inline", "loo", "pkgbuild", "rstan"), repos = c(" https://mc-stan.org/r-packages/", getOption("repos")))

Note I'm attempting to install ALL the packages from

https://mc-stan.org/r-packages/ FIRST, not only "StanHeaders" and "rstan". This will also work with the slightly broader option "dependencies = TRUE" inserted, instead of the default "dependencies = NA".

And that was all it took--everything worked.

On Sat, May 21, 2022 at 3:47 AM LeoS @.***> wrote:

Hi,

I'm using Windows 11 in Windows Insider Program and had the same issue. I managed to solve it by:

Removing the following packages: remove.packages(c("BH", "StanHeaders", "Rcpp", "RcppEigen", "RcppParallel", "inline", "loo", "pkgbuild", "rstan")) 2.

Restarting R 4.2.0 3.

Following https://github.com/stan-dev/rstan/wiki/Configuring-C---Toolchain-for-Windows for R4.0. I basically just copy-pasted the code. However, I changed 'writeLines('PATH="${RTOOLS40_HOME}\usr\bin;${PATH}"', con = "/.Renviron")' to 'writeLines('PATH="${RTOOLS42_HOME}\usr\bin;${PATH}"', con = " /.Renviron")' 4.

Then, install.packages(c("BH", "StanHeaders", "Rcpp", "RcppEigen", "RcppParallel", "inline", "loo", "pkgbuild", "rstan"), dependencies=T) 5.

I also ran install.packages("rstan", repos = c(" https://mc-stan.org/r-packages/", getOption("repos")))

I guess the steps 4 and 5 are somewhat redundant. But configuring the C toolchain for rtools 4.2 and configuring the makevars file probably did the trick.

— Reply to this email directly, view it on GitHub https://github.com/stan-dev/rstan/issues/1007#issuecomment-1133558248, or unsubscribe https://github.com/notifications/unsubscribe-auth/AY7BAO4BUESELTAUKE2MMGLVLCIJBANCNFSM5U223DZA . You are receiving this because you authored the thread.Message ID: @.***>

ploutal7 avatar May 21 '22 12:05 ploutal7

rstan and brms cause R 4.2.0 and RStudio session abort. Even re-installation of rstan and brmscause the error.

Same here. The solution,

install.packages(c("BH", "StanHeaders", "Rcpp", "RcppEigen", "RcppParallel",
                             "inline", "loo", "pkgbuild", "rstan"))

also fixed it for me.

rempsyc avatar Aug 10 '22 01:08 rempsyc

This page saved my day. I've been struggling so long with this issue.

install.packages(c("BH",`` "StanHeaders", "Rcpp", "RcppEigen", "RcppParallel", "inline", "loo", "pkgbuild", "rstan"))

This worked out for me. Lots of appreciation!

knowbrightly avatar Mar 31 '23 08:03 knowbrightly

rstan and brms cause R 4.2.0 and RStudio session abort. Even re-installation of rstan and brmscause the error.

enter image description here

enter image description here

sessionInfo()
R version 4.2.0 (2022-04-22 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 22000)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.utf8 
[2] LC_CTYPE=English_United States.utf8   
[3] LC_MONETARY=English_United States.utf8
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.utf8    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods  
[7] base     

loaded via a namespace (and not attached):
[1] compiler_4.2.0 tools_4.2.0    pacman_0.5.1 

hello, I wonder if you had deal with the problem? Thank you!

whzhuscu avatar May 10 '23 13:05 whzhuscu

I don't use Rstudio so I'm not a good contact for this. Also, you're using R 4.2.0, and the most recent version is R 4.2.3. I was able to run the examples from package rstan without problem using R 4.2.3, but it's the *same *procedure I followed to get around R crashing in R 4.2.0:

  1. First, open R and run this command: remove.packages(c("BH", "StanHeaders", "Rcpp", "RcppEigen", "RcppParallel", "inline", "loo", "pkgbuild", "rstan"))
  2. Then quit and restart R, and run this command: install.packages(c("BH", "StanHeaders", "Rcpp", "RcppEigen", "RcppParallel", "inline", "loo", "pkgbuild", "rstan"), repos = c(" https://mc-stan.org/r-packages/", getOption("repos"))) # Note I'm attempting to install ALL the packages from https://mc-stan.org/r-packages/ FIRST, not only "StanHeaders" and "rstan". This will also work with the slightly broader option "dependencies = TRUE" inserted, instead of the default "dependencies = NA".
    1. You don't need to include anything that appears after the "#" in the command above--that's just a comment explaining how the command works, and it mentions another option that also works with the "dependencies" parameter.

Good luck, Paul

On Wed, May 10, 2023 at 9:50 AM whzhuscu @.***> wrote:

rstan and brms cause R 4.2.0 and RStudio session abort. Even re-installation of rstan and brmscause the error.

[image: enter image description here] https://i.stack.imgur.com/HFf3U.png

[image: enter image description here] https://i.stack.imgur.com/6OZ1M.png

sessionInfo() R version 4.2.0 (2022-04-22 ucrt) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 22000)

Matrix products: default

locale: [1] LC_COLLATE=English_United States.utf8 [2] LC_CTYPE=English_United States.utf8 [3] LC_MONETARY=English_United States.utf8 [4] LC_NUMERIC=C [5] LC_TIME=English_United States.utf8

attached base packages: [1] stats graphics grDevices utils datasets methods [7] base

loaded via a namespace (and not attached): [1] compiler_4.2.0 tools_4.2.0 pacman_0.5.1

hello, I wonder if you had deal with the problem? Thank you!

— Reply to this email directly, view it on GitHub https://github.com/stan-dev/rstan/issues/1007#issuecomment-1542253413, or unsubscribe https://github.com/notifications/unsubscribe-auth/AY7BAO6YSYKEB35CVON4IADXFOMKHANCNFSM5U223DZA . You are receiving this because you authored the thread.Message ID: @.***>

ploutal7 avatar May 10 '23 15:05 ploutal7

RStudio did not abort after installing the dependencies mentioned above, but when I ran the rstan functions to fit the model, it returned an error.

I finally resolved the issue by downgrading from R 4.2.1 to 4.1.3 and Rtools42 to Rtools40. It appears that R 4.2 and Rtools42 are not yet compatible with the stan package.

Interestingly, it works fine with R 4.2 and Rtools42 on my laptop, but not in my desktop. It seems to vary from device to device.

These links might be helpful:

RStan error in R 4.2.2 (not in R 4.1.3) Stan & R 4.2 on Windows

knowbrightly avatar May 11 '23 02:05 knowbrightly

i would recommend using cmdstan and cmdstanr - much more stable and I have zero issues with it

jgman86 avatar May 21 '23 08:05 jgman86

I have the same problem. I first had this problem with my Windows. And I solved it. It was ok on my mac, but now it doesn't work on Mac at all. When I run "example(stan_model, package = "rstan", run.dontrun = TRUE)", Rstudio crashes with "fatal error". Tried everything on the Stan forums but nothing worked.

R version 4.3.0 (2023-04-21) Platform: aarch64-apple-darwin20 (64-bit)

Matrix products: default BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.11.0

locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: Asia/Seoul tzcode source: internal

attached base packages: [1] stats graphics grDevices utils datasets methods base

loaded via a namespace (and not attached): [1] tensorA_0.36.2 utf8_1.2.3 generics_0.1.3
[4] stringi_1.7.12 digest_0.6.31 magrittr_2.0.3
[7] grid_4.3.0 pkgload_1.3.2 fastmap_1.1.1
[10] processx_3.8.1 pkgbuild_1.4.0 sessioninfo_1.2.2
[13] backports_1.4.1 urlchecker_1.0.1 ps_1.7.5
[16] promises_1.2.0.1 fansi_1.0.4 purrr_1.0.1
[19] scales_1.2.1 abind_1.4-5 cli_3.6.1
[22] shiny_1.7.4 rlang_1.1.1 crayon_1.5.2
[25] cmdstanr_0.5.3 ellipsis_0.3.2 munsell_0.5.0
[28] remotes_2.4.2 cachem_1.0.8 devtools_2.4.5
[31] tools_4.3.0 memoise_2.0.1 checkmate_2.2.0
[34] dplyr_1.1.2 colorspace_2.1-0 ggplot2_3.4.2
[37] httpuv_1.6.11 vctrs_0.6.2 posterior_1.4.1
[40] R6_2.5.1 mime_0.12 lifecycle_1.0.3
[43] stringr_1.5.0 fs_1.6.2 htmlwidgets_1.6.2
[46] usethis_2.1.6 miniUI_0.1.1.1 pkgconfig_2.0.3
[49] callr_3.7.3 pillar_1.9.0 later_1.3.1
[52] gtable_0.3.3 glue_1.6.2 profvis_0.3.8
[55] Rcpp_1.0.10 xfun_0.39 tidyselect_1.2.0
[58] tibble_3.2.1 knitr_1.43 rstudioapi_0.14
[61] farver_2.1.1 xtable_1.8-4 htmltools_0.5.5
[64] compiler_4.3.0 prettyunits_1.1.1 distributional_0.3.2

kjayhan avatar Jun 05 '23 13:06 kjayhan

I have the same problem. I first had this problem with my Windows. And I solved it. It was ok on my mac, but now it doesn't work on Mac at all. When I run "example(stan_model, package = "rstan", run.dontrun = TRUE)", Rstudio crashes with "fatal error". Tried everything on the Stan forums but nothing worked.

R version 4.3.0 (2023-04-21) Platform: aarch64-apple-darwin20 (64-bit)

Matrix products: default BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.11.0

locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: Asia/Seoul tzcode source: internal

attached base packages: [1] stats graphics grDevices utils datasets methods base

loaded via a namespace (and not attached): [1] tensorA_0.36.2 utf8_1.2.3 generics_0.1.3 [4] stringi_1.7.12 digest_0.6.31 magrittr_2.0.3 [7] grid_4.3.0 pkgload_1.3.2 fastmap_1.1.1 [10] processx_3.8.1 pkgbuild_1.4.0 sessioninfo_1.2.2 [13] backports_1.4.1 urlchecker_1.0.1 ps_1.7.5 [16] promises_1.2.0.1 fansi_1.0.4 purrr_1.0.1 [19] scales_1.2.1 abind_1.4-5 cli_3.6.1 [22] shiny_1.7.4 rlang_1.1.1 crayon_1.5.2 [25] cmdstanr_0.5.3 ellipsis_0.3.2 munsell_0.5.0 [28] remotes_2.4.2 cachem_1.0.8 devtools_2.4.5 [31] tools_4.3.0 memoise_2.0.1 checkmate_2.2.0 [34] dplyr_1.1.2 colorspace_2.1-0 ggplot2_3.4.2 [37] httpuv_1.6.11 vctrs_0.6.2 posterior_1.4.1 [40] R6_2.5.1 mime_0.12 lifecycle_1.0.3 [43] stringr_1.5.0 fs_1.6.2 htmlwidgets_1.6.2 [46] usethis_2.1.6 miniUI_0.1.1.1 pkgconfig_2.0.3 [49] callr_3.7.3 pillar_1.9.0 later_1.3.1 [52] gtable_0.3.3 glue_1.6.2 profvis_0.3.8 [55] Rcpp_1.0.10 xfun_0.39 tidyselect_1.2.0 [58] tibble_3.2.1 knitr_1.43 rstudioapi_0.14 [61] farver_2.1.1 xtable_1.8-4 htmltools_0.5.5 [64] compiler_4.3.0 prettyunits_1.1.1 distributional_0.3.2

I got it to work on my Windows after deleting renv folder in one of my project folders which is on Onedrive (shared across Windows and Mac). I think that was the main problem.

kjayhan avatar Jun 06 '23 05:06 kjayhan

This has evolved to a different issue than the one I opened, which was on Windows 10 for rstan in R 4.2.0 and Rtools 4.2 (not Rstudio). The fix I published above on May 1, 2022 with the help / suggestions of several people continues to work on my Windows 10 machine with R 4.3.0 and Rtools 4.3.

Users with other issues (not every crash has the same cause), e.g., on a Mac OS / Rstudio should open a new thread.

ploutal7 avatar Jun 06 '23 16:06 ploutal7

Everyone, This has evolved to a different issue than the one I opened, which was on Windows 10 for rstan in R 4.2.0 and Rtools 4.2 (not Rstudio). The fix I put on GitHub (May 1, 2022) with the help / suggestions of several people continues to work on my Windows 10 machine with R 4.3.0 and Rtools 4.3. Hence, I've closed the thread, something I should have done as soon as I found the fix.

People who are having problems with a Mac OS / Rstudio should open a *new *thread on GitHub. Not every crash has the same cause, and asking for help under the thread I started won't get the attention of developers for separate issues.

Paul

On Tue, Jun 6, 2023 at 1:47 AM Kadir Jun Ayhan @.***> wrote:

I have the same problem. I first had this problem with my Windows. And I solved it. It was ok on my mac, but now it doesn't work on Mac at all. When I run "example(stan_model, package = "rstan", run.dontrun = TRUE)", Rstudio crashes with "fatal error". Tried everything on the Stan forums but nothing worked.

R version 4.3.0 (2023-04-21) Platform: aarch64-apple-darwin20 (64-bit)

Matrix products: default BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.11.0

locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: Asia/Seoul tzcode source: internal

attached base packages: [1] stats graphics grDevices utils datasets methods base

loaded via a namespace (and not attached): [1] tensorA_0.36.2 utf8_1.2.3 generics_0.1.3 [4] stringi_1.7.12 digest_0.6.31 magrittr_2.0.3 [7] grid_4.3.0 pkgload_1.3.2 fastmap_1.1.1 [10] processx_3.8.1 pkgbuild_1.4.0 sessioninfo_1.2.2 [13] backports_1.4.1 urlchecker_1.0.1 ps_1.7.5 [16] promises_1.2.0.1 fansi_1.0.4 purrr_1.0.1 [19] scales_1.2.1 abind_1.4-5 cli_3.6.1 [22] shiny_1.7.4 rlang_1.1.1 crayon_1.5.2 [25] cmdstanr_0.5.3 ellipsis_0.3.2 munsell_0.5.0 [28] remotes_2.4.2 cachem_1.0.8 devtools_2.4.5 [31] tools_4.3.0 memoise_2.0.1 checkmate_2.2.0 [34] dplyr_1.1.2 colorspace_2.1-0 ggplot2_3.4.2 [37] httpuv_1.6.11 vctrs_0.6.2 posterior_1.4.1 [40] R6_2.5.1 mime_0.12 lifecycle_1.0.3 [43] stringr_1.5.0 fs_1.6.2 htmlwidgets_1.6.2 [46] usethis_2.1.6 miniUI_0.1.1.1 pkgconfig_2.0.3 [49] callr_3.7.3 pillar_1.9.0 later_1.3.1 [52] gtable_0.3.3 glue_1.6.2 profvis_0.3.8 [55] Rcpp_1.0.10 xfun_0.39 tidyselect_1.2.0 [58] tibble_3.2.1 knitr_1.43 rstudioapi_0.14 [61] farver_2.1.1 xtable_1.8-4 htmltools_0.5.5 [64] compiler_4.3.0 prettyunits_1.1.1 distributional_0.3.2

I got it to work on my Windows after deleting renv file in one of my project folders which is on Onedrive (shared across Windows and Mac). I think that was the main problem.

— Reply to this email directly, view it on GitHub https://github.com/stan-dev/rstan/issues/1007#issuecomment-1577952891, or unsubscribe https://github.com/notifications/unsubscribe-auth/AY7BAO2O3FQVT2GR4X3CECTXJ276DANCNFSM5U223DZA . You are receiving this because you authored the thread.Message ID: @.***>

ploutal7 avatar Jun 06 '23 17:06 ploutal7