Unable to install RStan in Mac, El Capitan

254 views
Skip to first unread message

Ilan Strauss

unread,
Feb 24, 2016, 3:10:26 PM2/24/16
to Stan users mailing list
Hi,

Been trying for some time to install RStan in Mac, operating system is El Capitan. Here is my output:

-------------

> install.packages("rstan", dependencies = TRUE)
also installing the dependency ‘RcppEigen’


  There is a binary version available but the source
  version is later:
             binary    source needs_compilation
RcppEigen 0.3.2.7.0 0.3.2.8.0              TRUE

Do you want to install from sources the package which needs compilation?
y/n: y

[it then installs]

The downloaded binary packages are in
/var/folders/5j/j2glq8k55p904gq6r9858rmr0000gn/T//RtmpgzM5n3/downloaded_packages
installing the source package ‘RcppEigen’

[It then installs..]

* installing *source* package ‘RcppEigen’ ...
** package ‘RcppEigen’ successfully unpacked and MD5 sums checked
** libs
clang++ -arch x86_64 -ftemplate-depth-256 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG  -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -I"/Library/Frameworks/R.framework/Versions/3.2/Resources/library/Rcpp/include"  -I../inst/include -fPIC  -O3 -Wno-unused-variable -Wno-unused-function -Wno-unused-local-typedefs -c RcppEigen.cpp -o RcppEigen.o
clang++ -arch x86_64 -ftemplate-depth-256 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG  -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -I"/Library/Frameworks/R.framework/Versions/3.2/Resources/library/Rcpp/include"  -I../inst/include -fPIC  -O3 -Wno-unused-variable -Wno-unused-function -Wno-unused-local-typedefs -c RcppExports.cpp -o RcppExports.o
clang++ -arch x86_64 -ftemplate-depth-256 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG  -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -I"/Library/Frameworks/R.framework/Versions/3.2/Resources/library/Rcpp/include"  -I../inst/include -fPIC  -O3 -Wno-unused-variable -Wno-unused-function -Wno-unused-local-typedefs -c fastLm.cpp -o fastLm.o
clang++ -arch x86_64 -ftemplate-depth-256 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o RcppEigen.so RcppEigen.o RcppExports.o fastLm.o -L/Library/Frameworks/R.framework/Resources/lib -lRlapack -L/Library/Frameworks/R.framework/Resources/lib -lRblas -L/usr/local/lib/gcc/x86_64-apple-darwin13.0.0/4.8.2 -lgfortran -lquadmath -lm -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
ld: warning: directory not found for option '-L/usr/local/lib/gcc/x86_64-apple-darwin13.0.0/4.8.2'
ld: library not found for -lquadmath
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [RcppEigen.so] Error 1
ERROR: compilation failed for package ‘RcppEigen’
* removing ‘/Library/Frameworks/R.framework/Versions/3.2/Resources/library/RcppEigen’
Warning in install.packages :
  installation of package ‘RcppEigen’ had non-zero exit status

The downloaded source packages are in
‘/private/var/folders/5j/j2glq8k55p904gq6r9858rmr0000gn/T/RtmpgzM5n3/downloaded_packages’
-----------

I tried various things after looking at online forums but not much directly related to my issue (and I am no computer wizz).
 
Closest thing to my issue seems to be this: https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=16469#c2 (also since my Latex didnt work and I had to install a quick fix for that too). 

I have latest version of xQuartz, R, and R Studio. Installed Xcode (latest version). Tried uninstalling and reinstalling all of these but to no avail. Also tried installing EMacs. I have installed command line tools (http://stackoverflow.com/questions/32893412/command-line-tools-not-working-os-x-el-capitan). Not sure if these things made the issue better or worse (probably worse).

Many thanks for your help! Been struggling with this for a day and a half now.

Ilan Strauss

Jiqiang Guo

unread,
Feb 24, 2016, 3:49:50 PM2/24/16
to stan-...@googlegroups.com
Can you try please just using the binary rcppeigen package?

Jiqiang 
--
You received this message because you are subscribed to the Google Groups "Stan users mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to stan-users+...@googlegroups.com.
To post to this group, send email to stan-...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jonah Gabry

unread,
Feb 24, 2016, 3:50:42 PM2/24/16
to Stan users mailing list
Hi Ilan, 

Sorry you're getting these errors. It's not clear to me from looking at this that it is an RStan issue, as the errors you're seeing are from trying to install RcppEigen. RcppEigen is needed for RStan but it's a separate package. It looks like a new version of RcppEigen was just released yesterday, which is why you're getting that question (the binaries must not have built for Mac yet). I don't think installing the latest RcppEigen from source should give you these errors, so I'm not sure why that's happening (maybe someone else can clarify that), but what happens if you choose no instead of yes when it asks if you want to install RcppEigen from source?

Jonah


Jonah Gabry

unread,
Feb 24, 2016, 3:52:01 PM2/24/16
to stan-...@googlegroups.com
I hadn't seen Jiqiang's response, but his suggestion of installing the binary version is the same as answering no to the question about installing it from source when you're asked. 

Ben Goodrich

unread,
Feb 24, 2016, 3:55:09 PM2/24/16
to Stan users mailing list
On Wednesday, February 24, 2016 at 3:10:26 PM UTC-5, Ilan Strauss wrote:
ld: library not found for -lquadmath
clang: error: linker command failed with exit code 1 (use -v to see invocation)

It seems as if the quadmath library is not being found, but it is not used in Stan anyway. So, if you build from source, I would take out that flag by editing the ~/.R/Makevars file.

Ben

Ilan Strauss

unread,
Feb 24, 2016, 4:05:43 PM2/24/16
to stan-...@googlegroups.com
Many thanks for this!

While I was waiting for the (very quick and generous) responses I landed up doing what Nadine Gibson recommended:

https://groups.google.com/forum/#!msg/stan-users/lGIMXJf5P04/zZqOUsjlc1QJ


library(rstan)
set_cppo("fast")

And it seems to work now. Will let you know if I have any issues. 

Was this effectively the same as installing from Binary?

Many thanks,

Ilan

On Wed, Feb 24, 2016 at 4:04 PM, Ilan Strauss <ilans...@newschool.edu> wrote:
Many thanks for this!

While I was waiting for the (very quick and generous) responses I landed up doing what Nadine Gibson recommended:

https://groups.google.com/forum/#!msg/stan-users/lGIMXJf5P04/zZqOUsjlc1QJ


library(rstan)
set_cppo("fast")

And it seems to work now. Will let you know if I have any issues. 

Was this effectively the same as installing from Binary?

Many thanks,

Ilan

--
You received this message because you are subscribed to a topic in the Google Groups "Stan users mailing list" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/stan-users/-JyR9Z7F_rU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to stan-users+...@googlegroups.com.

To post to this group, send email to stan-...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Ilan Strauss
917-780 9730 (New York)



--

Jonah Gabry

unread,
Feb 24, 2016, 4:45:07 PM2/24/16
to Stan users mailing list
That's not the same as installing the binary version of RcppEigen. I think you actually installed an old version of Rstan (it looks like v2.6.0 instead of the latest version v2.9.0.3) by doing that. I would still recommend trying to install RcppEigen from binary (by saying no when it asks you if you want to install from source) and see if that will allow you to install the latest version of RStan. But if that doesn't work definitely let us know. 

Jonah Gabry

unread,
Feb 24, 2016, 4:47:37 PM2/24/16
to Stan users mailing list
Also, if you open terminal and run 

open .R/Makevars

What are the contents of that file?

Ilan Strauss

unread,
Feb 24, 2016, 4:52:34 PM2/24/16
to stan-...@googlegroups.com
Thanks for this, Jonah.

After typing:


install.packages("rstan", dependencies = TRUE)
also installing the dependency ‘BH’

...

The downloaded binary packages are in
/var/folders/5j/j2glq8k55p904gq6r9858rmr0000gn/T//Rtmprp2wOh/downloaded_packages

I wasn't asked about the 'y/n' dependancy. Seems to have installed fine BUT then when I load it into the library I guess the following which doesn't work:

> library(rstan)
Loading required package: ggplot2
Need help? Try the ggplot2 mailing list:
Error in get(method, envir = home) : 
  lazy-load database '/Library/Frameworks/R.framework/Versions/3.2/Resources/library/rstan/R/rstan.rdb' is corrupt
In addition: Warning message:
In get(method, envir = home) : internal error -3 in R_decompress1
Error: package or namespace load failed for ‘rstan’

> library("ggplot2")
> library(rstan)
Error in get(method, envir = home) : 
  lazy-load database '/Library/Frameworks/R.framework/Versions/3.2/Resources/library/rstan/R/rstan.rdb' is corrupt
In addition: Warning messages:
1: In .registerS3method(fin[i, 1], fin[i, 2], fin[i, 3], fin[i, 4],  :
  restarting interrupted promise evaluation
2: In get(method, envir = home) :
  restarting interrupted promise evaluation
3: In get(method, envir = home) : internal error -3 in R_decompress1
Error: package or namespace load failed for ‘rstan’

As to your other comment:
open .R/Makevars

CXXFLAGS=-O3 -Wno-unused-variable -Wno-unused-function -Wno-unused-local-typedefs

CC=clang
CXX=clang++ -arch x86_64 -ftemplate-depth-256

CXXFLAGS=-O3 -Wno-unused-variable -Wno-unused-function -Wno-unused-local-typedefs

CC=clang
CXX=clang++ -arch x86_64 -ftemplate-depth-256

CXXFLAGS=-O3 -Wno-unused-variable -Wno-unused-function -Wno-unused-local-typedefs  #set_by_rstan

CC=clang
CXX=clang++ -arch x86_64 -ftemplate-depth-256
R_XTRA_CPPFLAGS =  -I$(R_INCLUDE_DIR)   #set_by_rstan

What forward?

Thank again,

Ilan

--
You received this message because you are subscribed to a topic in the Google Groups "Stan users mailing list" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/stan-users/-JyR9Z7F_rU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to stan-users+...@googlegroups.com.
To post to this group, send email to stan-...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Jonah Sol Gabry

unread,
Feb 24, 2016, 5:08:55 PM2/24/16
to stan-...@googlegroups.com
If you do 

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

and then try installation does it then ask you again about installing RcppEigen from source vs binary? 
 

Ilan Strauss

unread,
Feb 24, 2016, 5:16:25 PM2/24/16
to stan-...@googlegroups.com
Yes. I did that command.

It then asks me again if I want source vs. binary. I now choose the other option ("n" i.e. binary).

It then installs RSTAN 100% fine. I then load RStan into the library. It says it needs "ggplot2" so I load that into the library before hand and all works well. Thank you!

Though I'm a bit scared to touch anything now. Feel like I'm in a bone China ornaments shop.

Output follows:


> install.packages("rstan", dependencies = TRUE)
also installing the dependencies ‘RcppEigen’, ‘BH’


  There is a binary version available but the source
  version is later:
             binary    source needs_compilation
RcppEigen 0.3.2.7.0 0.3.2.8.0              TRUE

Do you want to install from sources the package which needs compilation?
y/n: n

[...useless output follows and then:]


The downloaded binary packages are in
/var/folders/5j/j2glq8k55p904gq6r9858rmr0000gn/T//RtmpAQgY2n/downloaded_packages
> library(rstan)
Loading required package: ggplot2
rstan (Version 2.9.0-3, packaged: 2016-02-11 15:54:41 UTC, GitRev: 05c3d0058b6a)
For execution on a local, multicore CPU with excess RAM we recommend calling
rstan_options(auto_write = TRUE)
options(mc.cores = parallel::detectCores())
> library("ggplot2")
> library(rstan)

Jonah Sol Gabry

unread,
Feb 24, 2016, 5:39:18 PM2/24/16
to stan-...@googlegroups.com
Can you successfully run a Stan model? For example stan_demo('eight_schools')? It will probably ask you first if it's ok to install the demos.


On Wednesday, February 24, 2016, Ilan Strauss <ilans...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages