Error compiling stan program

I get an error message when brms is compiling the stan program.

> b3.1 <-
+   brm(data = list(w = 6), 
+       family = binomial(link = "identity"),
+       w | trials(9) ~ 0 + Intercept,
+       # this is a flat prior
+       prior(beta(1, 1), class = b, lb = 0, ub = 1),
+       seed = 3,
+       file = "fits/b03.01")
Compiling Stan program...
make cmd is
  make -f "C:/PROGRA~1/R/R-42~1.1/etc/x64/Makeconf" -f "C:/PROGRA~1/R/R-42~1.1/share/make/winshlib.mk" -f "C:\Users\dmalmgren\OneDrive - Specialist Prosecutorā€™s Office\Documents/.R/Makevars.win" CXX='$(CXX14) $(CXX14STD)' CXXFLAGS='$(CXX14FLAGS)' CXXPICFLAGS='$(CXX14PICFLAGS)' SHLIB_LDFLAGS='$(SHLIB_CXX14LDFLAGS)' SHLIB_LD='$(SHLIB_CXX14LD)' SHLIB="file4794139f6709.dll" WIN=64 TCLBIN= OBJECTS="file4794139f6709.o"

make would use
make: "C:\Users\dmalmgren\OneDrive - Specialist Prosecutorā€™s Office\Documents/.R/Makevars.win": No such file or directory
make: *** No rule to make target '"C:\Users\dmalmgren\OneDrive - Specialist Prosecutorā€™s Office\Documents/.R/Makevars.win"'.  Stop.
Error in compileCode(f, code, language = language, verbose = verbose) : 
  make: "C:\Users\dmalmgren\OneDrive - Specialist Prosecutorā€™s Office\Documents/.R/Makevars.win": No such file or directorymake: *** No rule to make target '"C:\Users\dmalmgren\OneDrive - Specialist Prosecutorā€™s Office\Documents/.R/Makevars.win"'.  Stop.
Error in sink(type = "output") : invalid connection
> 

  • Operating System: Win 10
  • brms Version: 2.17.0

Thx for your help

1 Like

Perhaps itā€™s because you are storing the file on Onedrive? Try save it on your local HD.

Thx for your answer. I have moved it and also changed the path to cmdstan to a folder on the local drive.
The I got the following error:

b3.1 ā†

  • brm(data = list(w = 6),
  •   family = binomial(link = "identity"),
    
  •   w | trials(9) ~ 0 + Intercept,
    
  •   # this is a flat prior
    
  •   prior(beta(1, 1), class = b, lb = 0, ub = 1),
    
  •   seed = 3,
    
  •   file = "fits/b03.01")
    

Compiling Stan programā€¦
Loading required package: rethinking
Loading required package: rstan
Loading required package: StanHeaders
Loading required package: ggplot2
rstan (Version 2.21.5, GitRev: 2e1f913d3ca3)
For execution on a local, multicore CPU with excess RAM we recommend calling
options(mc.cores = parallel::detectCores()).
To avoid recompilation of unchanged Stan programs, we recommend calling
rstan_options(auto_write = TRUE)
Do not specify ā€˜-march=nativeā€™ in ā€˜LOCAL_CPPFLAGSā€™ or a Makevars file
Loading required package: parallel
rethinking (Version 2.21)

Attaching package: ā€˜rethinkingā€™

The following object is masked from ā€˜package:rstanā€™:

stan

The following objects are masked from ā€˜package:brmsā€™:

LOO, stancode, WAIC

The following object is masked from ā€˜package:statsā€™:

rstudent

make cmd is
make -f ā€œC:/PROGRA~1/R/R-42~1.1/etc/x64/Makeconfā€ -f ā€œC:/PROGRA~1/R/R-42~1.1/share/make/winshlib.mkā€ CXX=ā€˜(CXX14) (CXX14STD)ā€™ CXXFLAGS=ā€˜(CXX14FLAGS)' CXXPICFLAGS='(CXX14PICFLAGS)ā€™ SHLIB_LDFLAGS=ā€˜(SHLIB_CXX14LDFLAGS)' SHLIB_LD='(SHLIB_CXX14LD)ā€™ SHLIB=ā€œfile4a784fc557d1.dllā€ WIN=64 TCLBIN= OBJECTS=ā€œfile4a784fc557d1.oā€

make would use
if test ā€œzfile4a784fc557d1.oā€ != ā€œzā€; then
if test -e ā€œfile4a784fc557d1-win.defā€; then
echo g++ -shared -s -static-libgcc -o file4a784fc557d1.dll file4a784fc557d1-win.def file4a784fc557d1.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.1/bin/x64" -lR ;
g++ -shared -s -static-libgcc -o file4a784fc557d1.dll file4a784fc557d1-win.def file4a784fc557d1.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.1/bin/x64" -lR ;
else
echo EXPORTS > tmp.def;
nm file4a784fc557d1.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 file4a784fc557d1.dll tmp.def file4a784fc557d1.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.1/bin/x64" -lR ;
g++ -shared -s -static-libgcc -o file4a784fc557d1.dll tmp.def file4a784fc557d1.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.1/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: file4a784fc557d1.o:file4a784fc557d1.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: file4a784fc557d1.o:file4a784fc557d1.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: file4a784fc557d1.o:file4a784fc557d1.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: file4a784fc557d1.o:file4a784fc557d1.cpp:(.text$_ZN3tbb10interface
Error in sink(type = ā€œoutputā€) : invalid connection

@andrjohns

1 Like

Weā€™re having some compatibility issues with R4.2 and the CRAN rstan, can I get you to restart your R session and then install the preview of the next rstan version using:

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

Thanks! Much appreciatedā€¦ brms is now working!

@andrjohns , so I got it to work, but now it has returnedā€¦ See below output

b5.1 ā†

  • brm(data = d,
  •   family = gaussian,
    
  •   Divorce ~ 1 + MedianAgeMarriage_s,
    
  •   prior = c(prior(normal(10, 10), class = Intercept),
    
  •             prior(normal(0, 1), class = b),
    
  •             prior(uniform(0, 10), class = sigma)),
    
  •   iter = 2000, warmup = 500, chains = 4, cores = 4,
    
  •   seed = 5,
    
  •   file = "fits/b05.01")
    

Compiling Stan programā€¦
Loading required package: rethinking
rethinking (Version 2.21)

Attaching package: ā€˜rethinkingā€™

The following objects are masked from ā€˜package:brmsā€™:

LOO, stancode, WAIC

The following object is masked from ā€˜package:rstanā€™:

stan

The following object is masked from ā€˜package:purrrā€™:

map

The following object is masked from ā€˜package:statsā€™:

rstudent

make cmd is
make -f ā€œC:/PROGRA~1/R/R-42~1.1/etc/x64/Makeconfā€ -f ā€œC:/PROGRA~1/R/R-42~1.1/share/make/winshlib.mkā€ CXX=ā€˜(CXX14) (CXX14STD)ā€™ CXXFLAGS=ā€˜(CXX14FLAGS)' CXXPICFLAGS='(CXX14PICFLAGS)ā€™ SHLIB_LDFLAGS=ā€˜(SHLIB_CXX14LDFLAGS)' SHLIB_LD='(SHLIB_CXX14LD)ā€™ SHLIB=ā€œfile37ac316f48a9.dllā€ WIN=64 TCLBIN= OBJECTS=ā€œfile37ac316f48a9.oā€

make would use
if test ā€œzfile37ac316f48a9.oā€ != ā€œzā€; then
if test -e ā€œfile37ac316f48a9-win.defā€; then
echo g++ -shared -s -static-libgcc -o file37ac316f48a9.dll file37ac316f48a9-win.def file37ac316f48a9.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.1/bin/x64" -lR ;
g++ -shared -s -static-libgcc -o file37ac316f48a9.dll file37ac316f48a9-win.def file37ac316f48a9.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.1/bin/x64" -lR ;
else
echo EXPORTS > tmp.def;
nm file37ac316f48a9.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 file37ac316f48a9.dll tmp.def file37ac316f48a9.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.1/bin/x64" -lR ;
g++ -shared -s -static-libgcc -o file37ac316f48a9.dll tmp.def file37ac316f48a9.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.1/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: file37ac316f48a9.o:file37ac316f48a9.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: file37ac316f48a9.o:file37ac316f48a9.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: file37ac316f48a9.o:file37ac316f48a9.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: file37ac316f48a9.o:file37ac316f48a9.cpp:(.text$_ZN3tbb10interface
In addition: Warning message:
It appears as if you have specified an upper bounded prior on a parameter that has no natural upper bound.
If this is really what you want, please specify argument ā€˜ubā€™ of ā€˜set_priorā€™ appropriately.
Warning occurred for prior
<lower=0> sigma ~ uniform(0, 10)

Error in sink(type = ā€œoutputā€) : invalid connection