Rstan Error Message on Mac: Error: vector memory exhausted (limit reached?)

Hi,
I am completely new to rstan. When I tried to use the example code provided,
my mac always shows the following error

Error: vector memory exhausted (limit reached?)

and I don’t know what to do.
Can someone help me with it?

I will really appreciate it.

Chang

My guess is that something is not installed correctly. Which example code were you trying to execute?

Thank you so much for such a fast response!!!

I tried to remove everything and reinstall it. Now it works on my Mac for the 8school example from
https://github.com/stan-dev/rstan/wiki/RStan-Getting-Started.

However, when I tried to use a windows to run the same example code, it shows the following error:

Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! sh: g++: command not found
make: *** [C:/PROGRA~1/R/R-36~1.0/etc/x64/Makeconf:215: file27b02dba6f84.o] Error 127
In addition: Warning message:
In system(cmd, intern = !verbose) :
running command ‘C:/PROGRA~1/R/R-36~1.0/bin/x64/R CMD SHLIB file27b02dba6f84.cpp 2> file27b02dba6f84.cpp.err.txt’ had status 1
Error in sink(type = “output”) : invalid connection

What should I do with the windows R? Thanks in advance!

Chang

What is the output of

pkgbuild::has_build_tools(debug = TRUE)

?

pkgbuild::has_build_tools(debug = TRUE)
TRUE

What is the output of

readLines("~/.R/Makevars")

?

readLines(“~/.R/Makevars”)
[1] “CXX14 = g++ -std=c++1y”
[2] “CXX14FLAGS = -O3 -Wno-unused-variable -Wno-unused-function”
[3] “CXX11FLAGS=-O3 -march=native -mtune=native”

Sys.which("make")

?

I got:

Sys.which(“make”)
make
“C:\Rtools\bin\make.exe”

Sys.getenv("PATH")

?

C:\Program Files\R\R-3.6.0\bin\x64;
C:\Rtools\bin;
C:\ProgramData\Oracle\Java\javapath;
C:\Program Files (x86)\Intel\iCLS Client\;
C:\Program Files\Intel\iCLS Client\;
C:\Windows\system32;
C:\Windows;C:\Windows\System32\Wbem;
C:\Windows\System32\WindowsPowerShell\v1.0\;
C:\Windows\System32\WindowsPowerShell\v1.0\;
C:\Windows\CCM;
C:\Program Files\Intel\WiFi\bin\;
C:\Program Files\Common Files\Intel\WirelessCommon\;
C:\Program Files (x86)\Intel\Intel® Management Engine Components\DAL;
C:\Program Files\Intel\Intel® Management Engine Components\DAL;
C:\Program Files (x86)\Intel\Intel® Management Engine Components\IPT;
C:\Program Files\Intel\Intel® Management Engine Components\IPT;
C:\Windows\System32\WindowsPowerShell\v1.0\;
C:\Windows\System32\WindowsPowerShell\v1.0\;
C:\texlive\2016\bin\win32;

When was Rtools installed on that machine?

Yesterday I just installed it.

Using version 35?

Yes.
I downloaded and installed Rtools35.exe as recommended.

Does this work?

Rcpp::sourceCpp(code='
  #include <Rcpp.h>

  // [[Rcpp::export]]
  int fibonacci(const int x) {
    if (x == 0) return(0);
    if (x == 1) return(1);
    return (fibonacci(x - 1)) + fibonacci(x - 2);
  }'
)

Hi I tried this code, there is no ouput in R.
Also no warning, nor error message. Is that normal?

Can you then call something like fibonacci(3)?

Yes, I got:

fibonacci(3)
[1] 2
fibonacci(4)
[1] 3
fibonacci(5)
[1] 5
fibonacci(0)
[1] 0
fibonacci(1)
[1] 1

I updated some packages (perhaps misguidedly and too late) and am now having the same issue “vector memory exhausted” even with the 8schools example. [Running on MacOS High Sierra]

When I run the above ^^, I get the following warning:
ld: warning: text-based stub file /System/Library/Frameworks//CoreFoundation.framework/CoreFoundation.tbd and library file /System/Library/Frameworks//CoreFoundation.framework/CoreFoundation are out of sync. Falling back to library file for linking.

The fibonnaci function itself works. I’ve tried reinstalling everything as per the usual instructions. Running the latest version of R and rstan on High Sierra.

Any idea of what’s going wrong?