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

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