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

#1

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

#2

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

#3

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

#4

What is the output of

pkgbuild::has_build_tools(debug = TRUE)

?

#5

pkgbuild::has_build_tools(debug = TRUE)
TRUE

#6

What is the output of

readLines("~/.R/Makevars")

?

#7

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”

#8
Sys.which("make")

?

#9

I got:

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

#10
Sys.getenv("PATH")

?

#11

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;

#12

When was Rtools installed on that machine?

#13

Yesterday I just installed it.

#14

Using version 35?

#15

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

#16

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);
  }'
)

#17

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

#18

Can you then call something like fibonacci(3)?

#19

Yes, I got:

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