stan-dev / rstan

RStan, the R interface to Stan
https://mc-stan.org
1.03k stars 264 forks source link

Failed installation of Rstan #153

Closed Sofieseidenfaden closed 9 years ago

Sofieseidenfaden commented 9 years ago

Hi all,

I have some trouble installing Rstan on my computer and I can't figure out what is wrong.

I have a Mac OS.X 10.7.5. I have recently upgraded my R to 3.1.3 and I use R-studio as an interface. For the installation of Rstan I have followed the description from here: https://github.com/stan-dev/rstan/wiki/RStan-Mac-OS-X-Prerequisite-Installation-Instructions

I have installed X-code and the Command Line Tools (Mac OS.X Lion) through Apple Developer and when I check in R whether is installed, I get this message:

system('clang++ -v') Apple LLVM version 4.2 (clang-425.0.28) (based on LLVM 3.2svn) Target: x86_64-apple-darwin11.4.2 Thread model: posix
When I install Stan in R, I get following message:

Install STAN - https://github.com/stan-dev/rstan/wiki/RStan-Getting-Started

Step 1 - Set numbers of processes to uge

Sys.setenv(MAKEFLAGS = "-j4")

Step 2 - Run the script

source('http://mc-stan.org/rstan/install.R', echo = TRUE, max.deparse.length = 2000)

install_rstan <- function() {

  • on.exit(Sys.unsetenv("R_MAKEVARS_USER"))
  • on.exit(Sys.unsetenv("R_MAKEVARS_SITE"), add = TRUE)
  • try(remove.packages("rstan"), silent = TRUE)
  • Sys.setenv(R_MAKEVARS_USER = "foobar")
  • Sys.setenv(R_MAKEVARS_SITE = "foobar")
  • install.packages(c("inline", "BH", "RcppEigen"))
  • install.packages("Rcpp", type = "source")
  • library(inline)
  • library(Rcpp)
  • src <- '
  • std::vectorstd::string s;
  • s.push_back("hello");
  • s.push_back("world");
  • return Rcpp::wrap(s);
  • '
  • hellofun <- cxxfunction(body = src, includes = '', plugin = 'Rcpp', verbose = FALSE)
  • test <- try(hellofun())
  • if(inherits(test, "try-error")) stop("hello world failed; ask for help on Rcpp list")
  • options(repos = c(getOption("repos"),
  • rstan = "http://rstan.org/repo/"))
  • install.packages("rstan", type = 'source')
  • library(rstan)
  • set_cppo("fast")
  • if (any(grepl("^darwin", R.version$os, ignore.case = TRUE))) {
  • cat('\nCC=clang', 'CXX=clang++ -arch x86_64 -ftemplate-depth-256',
  • file = "~/.R/Makevars", sep = "\n", append = TRUE)
  • }
  • return(invisible(NULL))
  • } install_rstan() Removing package from ‘/Library/Frameworks/R.framework/Versions/3.1/Resources/library’ (as ‘lib’ is unspecified) Error in remove.packages : there is no package called ‘rstan’ trying URL 'http://cran.rstudio.com/bin/macosx/contrib/3.1/inline_0.3.13.tgz' Content type 'application/x-gzip' length 78503 bytes (76 KB) opened URL

    downloaded 76 KB

trying URL 'http://cran.rstudio.com/bin/macosx/contrib/3.1/BH_1.55.0-3.tgz' Content type 'application/x-gzip' length 7455235 bytes (7.1 MB)

opened URL

downloaded 7.1 MB

trying URL 'http://cran.rstudio.com/bin/macosx/contrib/3.1/RcppEigen_0.3.2.4.0.tgz' Content type 'application/x-gzip' length 3335332 bytes (3.2 MB)

opened URL

downloaded 3.2 MB

The downloaded binary packages are in /var/folders/0x/zkhg5kyd7j3199jkj76v9p340000gn/T//Rtmpk2CfrS/downloaded_packages Error in install.packages : Updating loaded packages

Attaching package: ‘inline’

The following object is masked from ‘package:Rcpp’:

registerPlugin

trying URL 'http://rstan.org/repo/src/contrib/rstan_2.6.0.tar.gz' Content type 'application/x-gzip' length 1423850 bytes (1.4 MB)

opened URL

downloaded 1.4 MB

ERROR: failed to lock directory ‘/Library/Frameworks/R.framework/Versions/3.1/Resources/library’ for modifying Try removing ‘/Library/Frameworks/R.framework/Versions/3.1/Resources/library/00LOCK-rstan’ Warning in install.packages : installation of package ‘rstan’ had non-zero exit status

The downloaded source packages are in ‘/private/var/folders/0x/zkhg5kyd7j3199jkj76v9p340000gn/T/Rtmpk2CfrS/downloaded_packages’ Fejl i library(rstan) : there is no package called ‘rstan’ Called from: top level

Restarting R session...

install.packages("Rcpp", type = "source") trying URL 'http://cran.rstudio.com/src/contrib/Rcpp_0.11.5.tar.gz' Content type 'application/x-gzip' length 2353791 bytes (2.2 MB)

opened URL

downloaded 2.2 MB

  • installing source package ‘Rcpp’ ... * package ‘Rcpp’ successfully unpacked and MD5 sums checked * libs llvm-g++-4.2 -arch x86_64 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I../inst/include/ -I/usr/local/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -fPIC -mtune=core2 -g -O2 -c Date.cpp -o Date.o llvm-g++-4.2 -arch x86_64 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I../inst/include/ -I/usr/local/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -fPIC -mtune=core2 -g -O2 -c Module.cpp -o Module.o llvm-g++-4.2 -arch x86_64 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I../inst/include/ -I/usr/local/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -fPIC -mtune=core2 -g -O2 -c Rcpp_init.cpp -o Rcpp_init.o llvm-g++-4.2 -arch x86_64 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I../inst/include/ -I/usr/local/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -fPIC -mtune=core2 -g -O2 -c api.cpp -o api.o llvm-g++-4.2 -arch x86_64 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I../inst/include/ -I/usr/local/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -fPIC -mtune=core2 -g -O2 -c attributes.cpp -o attributes.o llvm-g++-4.2 -arch x86_64 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I../inst/include/ -I/usr/local/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -fPIC -mtune=core2 -g -O2 -c barrier.cpp -o barrier.o llvm-g++-4.2 -arch x86_64 -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 -L/usr/local/lib -o Rcpp.so Date.o Module.o Rcpp_init.o api.o attributes.o barrier.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation installing to /Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/libs * R * inst * preparing package for lazy loading * help ** installing help indices * building package indices * installing vignettes * testing if installed package can be loaded
  • DONE (Rcpp)

The downloaded source packages are in ‘/private/var/folders/0x/zkhg5kyd7j3199jkj76v9p340000gn/T/RtmpZSUb93/downloaded_packages’

When I load Rstan: source("http://mc-stan.org/rstan/stan.R") I get the message that the package rstan doesn't exist.

I hope somebody will be able to help me. Thank you in advance!

Best, Sofie

bob-carpenter commented 9 years ago

See:

http://stackoverflow.com/questions/23483303/error-failed-to-lock-directory-c-program-files-r-r-3-0-2-library-for-modifyi

On Apr 11, 2015, at 5:35 AM, Sofieseidenfaden notifications@github.com wrote:

Hi all,

I have some trouble installing Rstan on my computer and I can't figure out what is wrong.

I have a Mac OS.X 10.7.5. I have recently upgraded my R to 3.1.3 and I use R-studio as an interface. For the installation of Rstan I have followed the description from here: https://github.com/stan-dev/rstan/wiki/RStan-Mac-OS-X-Prerequisite-Installation-Instructions

I have installed X-code and the Command Line Tools (Mac OS.X Lion) through Apple Developer and when I check in R whether is installed, I get this message:

system('clang++ -v') Apple LLVM version 4.2 (clang-425.0.28) (based on LLVM 3.2svn) Target: x86_64-apple-darwin11.4.2 Thread model: posix

When I install Stan in R, I get following message:

Install STAN - https://github.com/stan-dev/rstan/wiki/RStan-Getting-Started

Step 1 - Set numbers of processes to uge

Sys.setenv(MAKEFLAGS = "-j4")

Step 2 - Run the script

source('http://mc-stan.org/rstan/install.R', echo = TRUE, max.deparse.length = 2000)

install_rstan <- function() {

• on.exit(Sys.unsetenv("R_MAKEVARS_USER")) • on.exit(Sys.unsetenv("R_MAKEVARS_SITE"), add = TRUE) • • try(remove.packages("rstan"), silent = TRUE) • Sys.setenv(R_MAKEVARS_USER = "foobar") • Sys.setenv(R_MAKEVARS_SITE = "foobar") • install.packages(c("inline", "BH", "RcppEigen")) • install.packages("Rcpp", type = "source") • library(inline) • library(Rcpp) • src <- ' • std::vectorstd::string s; • s.push_back("hello"); • s.push_back("world"); • return Rcpp::wrap(s); • ' • hellofun <- cxxfunction(body = src, includes = '', plugin = 'Rcpp', verbose = FALSE) • test <- try(hellofun()) • if(inherits(test, "try-error")) stop("hello world failed; ask for help on Rcpp list") • • options(repos = c(getOption("repos"), • rstan = "http://rstan.org/repo/")) • install.packages("rstan", type = 'source') • library(rstan) • set_cppo("fast") • if (any(grepl("^darwin", R.version$os, ignore.case = TRUE))) { • cat('\nCC=clang', 'CXX=clang++ -arch x86_64 -ftemplate-depth-256', • file = "~/.R/Makevars", sep = "\n", append = TRUE) • } • return(invisible(NULL)) • } install_rstan() Removing package from ‘/Library/Frameworks/R.framework/Versions/3.1/Resources/library’ (as ‘lib’ is unspecified) Error in remove.packages : there is no package called ‘rstan’ trying URL 'http://cran.rstudio.com/bin/macosx/contrib/3.1/inline_0.3.13.tgz' Content type 'application/x-gzip' length 78503 bytes (76 KB) opened URL ================================================== downloaded 76 KB trying URL 'http://cran.rstudio.com/bin/macosx/contrib/3.1/BH_1.55.0-3.tgz' Content type 'application/x-gzip' length 7455235 bytes (7.1 MB)

opened URL

downloaded 7.1 MB

trying URL 'http://cran.rstudio.com/bin/macosx/contrib/3.1/RcppEigen_0.3.2.4.0.tgz' Content type 'application/x-gzip' length 3335332 bytes (3.2 MB)

opened URL

downloaded 3.2 MB

The downloaded binary packages are in /var/folders/0x/zkhg5kyd7j3199jkj76v9p340000gn/T//Rtmpk2CfrS/downloaded_packages Error in install.packages : Updating loaded packages

Attaching package: ‘inline’

The following object is masked from ‘package:Rcpp’:

registerPlugin

trying URL 'http://rstan.org/repo/src/contrib/rstan_2.6.0.tar.gz' Content type 'application/x-gzip' length 1423850 bytes (1.4 MB)

opened URL

downloaded 1.4 MB

ERROR: failed to lock directory ‘/Library/Frameworks/R.framework/Versions/3.1/Resources/library’ for modifying Try removing ‘/Library/Frameworks/R.framework/Versions/3.1/Resources/library/00LOCK-rstan’ Warning in install.packages : installation of package ‘rstan’ had non-zero exit status

The downloaded source packages are in ‘/private/var/folders/0x/zkhg5kyd7j3199jkj76v9p340000gn/T/Rtmpk2CfrS/downloaded_packages’ Fejl i library(rstan) : there is no package called ‘rstan’ Called from: top level

Restarting R session...

install.packages("Rcpp", type = "source") trying URL 'http://cran.rstudio.com/src/contrib/Rcpp_0.11.5.tar.gz' Content type 'application/x-gzip' length 2353791 bytes (2.2 MB)

opened URL

downloaded 2.2 MB

• installing source package ‘Rcpp’ ... * package ‘Rcpp’ successfully unpacked and MD5 sums checked * libs llvm-g++-4.2 -arch x86_64 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I../inst/include/ -I/usr/local/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -fPIC -mtune=core2 -g -O2 -c Date.cpp -o Date.o llvm-g++-4.2 -arch x86_64 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I../inst/include/ -I/usr/local/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -fPIC -mtune=core2 -g -O2 -c Module.cpp -o Module.o llvm-g++-4.2 -arch x86_64 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I../inst/include/ -I/usr/local/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -fPIC -mtune=core2 -g -O2 -c Rcpp_init.cpp -o Rcpp_init.o llvm-g++-4.2 -arch x86_64 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I../inst/include/ -I/usr/local/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -fPIC -mtune=core2 -g -O2 -c api.cpp -o api.o llvm-g++-4.2 -arch x86_64 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I../inst/include/ -I/usr/local/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -fPIC -mtune=core2 -g -O2 -c attributes.cpp -o attributes.o llvm-g++-4.2 -arch x86_64 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I../inst/include/ -I/usr/local/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -fPIC -mtune=core2 -g -O2 -c barrier.cpp -o barrier.o llvm-g++-4.2 -arch x86_64 -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 -L/usr/local/lib -o Rcpp.so Date.o Module.o Rcpp_init.o api.o attributes.o barrier.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation installing to /Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/libs * R * inst * preparing package for lazy loading * help ** installing help indices * building package indices * installing vignettes * testing if installed package can be loaded • DONE (Rcpp) The downloaded source packages are in ‘/private/var/folders/0x/zkhg5kyd7j3199jkj76v9p340000gn/T/RtmpZSUb93/downloaded_packages’

When I load Rstan: source("http://mc-stan.org/rstan/stan.R") I get the message that the package rstan doesn't exist.

I hope somebody will be able to help me. Thank you in advance!

Best, Sofie

— Reply to this email directly or view it on GitHub.

Sofieseidenfaden commented 9 years ago

Dear Bob,

Thank you for this link. From this post I have tried to remove this directory: /Library/Frameworks/R.framework/Versions/3.1/Resources/library/00LOCK-rstan

Unfortunately, this directory doesn't seem to exist. Would you recommend me to uninstall R (and R Studio) and afterwards reinstall? Just to be sure, can I use R version 3.1.3, because I also get a warning message that rstan as a binary package doesn't work with R 3.1.3.

This might be a stupid question, but I am not really a skilled programmer, but I need Rstan for graduate course.

Best, Sofie

bob-carpenter commented 9 years ago

If it's not problematic for you to reinstall R, that should clear up the problem. There must be a better way to do this, but none of the devs who actually know R are chiming in here.

I don't think there is an rstan binary package yet. I do believe you get warnings that various things are built with older packages.

Is there a way to clean this up on the R side so that we don't confuse users?

On Apr 12, 2015, at 8:16 AM, Sofieseidenfaden notifications@github.com wrote:

Dear Bob,

Thank you for this link. From this post I have tried to remove this directory: /Library/Frameworks/R.framework/Versions/3.1/Resources/library/00LOCK-rstan

Unfortunately, this directory doesn't seem to exist. Would you recommend me to uninstall R (and R Studio) and afterwards reinstall? Just to be sure, can I use R version 3.1.3, because I also get a warning message that rstan as a binary package doesn't work with R 3.1.3.

This might be a stupid question, but I am not really a skilled programmer, but I need Rstan for graduate course.

Best, Sofie

— Reply to this email directly or view it on GitHub.

Sofieseidenfaden commented 9 years ago

Hi Bob,

Thank you again. Reinstallation didn't unfortunately help. Is there somewhere it possible to get online support on Rstan?

/Sofie

bgoodri commented 9 years ago

I still don't see what the error message is for rstan when the 00Lock directory is removed.

Sofieseidenfaden commented 9 years ago

@bgoodri: This might seem very banal, but I simply don't know how I remove it.. I have tried in Finder, I have tried to find the directory in the R-folder, but without any luck.

bgoodri commented 9 years ago

In R, you can just do

system("rm -rf /Library/Frameworks/R.framework/Versions/3.1/Resources/library/00LOCK-rstan")

or whatever is the path to the 00LOCK-rstan directory. Once that is removed, we can hopefully see what the underlying error is.

Sofieseidenfaden commented 9 years ago

@bgoodri: This took some time. I had to shut down my computer and R studio down a few times. It still doesn't work for me. Here is the whole message I get when I install, run the 'source'-command and try to apply the stan package on a model.

Attached is a picture of the install_rstan and stan in my enviroment! rstan installation

Getting started

setwd("~/Desktop/Columbia /3. Sample Survey and Analysis/R data") getwd() # Let's check that this is the right directory [1] "/Users/sofieseidenfaden/Desktop/Columbia /3. Sample Survey and Analysis/R data" rm(list=ls()) # clears objects in memory library(arm) Indlæser krævet pakke: MASS Indlæser krævet pakke: Matrix Indlæser krævet pakke: lme4 Indlæser krævet pakke: Rcpp

arm (Version 1.7-07, built: 2014-8-27)

Working directory is /Users/sofieseidenfaden/Desktop/Columbia /3. Sample Survey and Analysis/R data

library(foreign)

Install STAN - https://github.com/stan-dev/rstan/wiki/RStan-Getting-Started

Step 1 - Set numbers of processes to uge

Sys.setenv(MAKEFLAGS = "-j4") system("rm -rf /Library/Frameworks/R.framework/Versions/3.1/Resources/library/00LOCK-rstan")

Step 2 - Run the script

source('http://mc-stan.org/rstan/install.R', echo = TRUE, max.deparse.length = 2000)

install_rstan <- function() {

  • on.exit(Sys.unsetenv("R_MAKEVARS_USER"))
  • on.exit(Sys.unsetenv("R_MAKEVARS_SITE"), add = TRUE)
  • try(remove.packages("rstan"), silent = TRUE)
  • Sys.setenv(R_MAKEVARS_USER = "foobar")
  • Sys.setenv(R_MAKEVARS_SITE = "foobar")
  • install.packages(c("inline", "BH", "RcppEigen"))
  • install.packages("Rcpp", type = "source")
  • library(inline)
  • library(Rcpp)
  • src <- '
  • std::vectorstd::string s;
  • s.push_back("hello");
  • s.push_back("world");
  • return Rcpp::wrap(s);
  • '
  • hellofun <- cxxfunction(body = src, includes = '', plugin = 'Rcpp', verbose = FALSE)
  • test <- try(hellofun())
  • if(inherits(test, "try-error")) stop("hello world failed; ask for help on Rcpp list")
  • options(repos = c(getOption("repos"),
  • rstan = "http://rstan.org/repo/"))
  • install.packages("rstan", type = 'source')
  • library(rstan)
  • set_cppo("fast")
  • if (any(grepl("^darwin", R.version$os, ignore.case = TRUE))) {
  • cat('\nCC=clang', 'CXX=clang++ -arch x86_64 -ftemplate-depth-256',
  • file = "~/.R/Makevars", sep = "\n", append = TRUE)
  • }
  • return(invisible(NULL))
  • } install_rstan() Removing package from ‘/Library/Frameworks/R.framework/Versions/3.1/Resources/library’ (as ‘lib’ is unspecified) Error in remove.packages : there is no package called ‘rstan’ trying URL 'http://cran.rstudio.com/bin/macosx/contrib/3.1/inline_0.3.13.tgz' Content type 'application/x-gzip' length 78503 bytes (76 KB) opened URL

    downloaded 76 KB

trying URL 'http://cran.rstudio.com/bin/macosx/contrib/3.1/BH_1.55.0-3.tgz' Content type 'application/x-gzip' length 7455235 bytes (7.1 MB)

opened URL

downloaded 7.1 MB

trying URL 'http://cran.rstudio.com/bin/macosx/contrib/3.1/RcppEigen_0.3.2.4.0.tgz' Content type 'application/x-gzip' length 3335332 bytes (3.2 MB)

opened URL

downloaded 3.2 MB

The downloaded binary packages are in /var/folders/0x/zkhg5kyd7j3199jkj76v9p340000gn/T//RtmpYD83HK/downloaded_packages Error in install.packages : Updating loaded packages

Attaching package: ‘inline’

The following object is masked from ‘package:Rcpp’:

registerPlugin

Restarting R session...

Warning message: In save(opt, file = filename) : 'package:stats' er måske ikke tilgængelig under indlæsning

install.packages("Rcpp", type = "source") Error in get(name, envir = asNamespace(pkg), inherits = FALSE) : promise already under evaluation: recursive default argument reference or earlier problems? trying URL 'http://cran.rstudio.com/src/contrib/Rcpp_0.11.5.tar.gz' Content type 'application/x-gzip' length 2353791 bytes (2.2 MB)

opened URL

downloaded 2.2 MB

  • installing source package ‘Rcpp’ ... * package ‘Rcpp’ successfully unpacked and MD5 sums checked * libs llvm-g++-4.2 -arch x86_64 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I../inst/include/ -I/usr/local/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -fPIC -mtune=core2 -g -O2 -c Date.cpp -o Date.o llvm-g++-4.2 -arch x86_64 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I../inst/include/ -I/usr/local/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -fPIC -mtune=core2 -g -O2 -c Module.cpp -o Module.o llvm-g++-4.2 -arch x86_64 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I../inst/include/ -I/usr/local/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -fPIC -mtune=core2 -g -O2 -c Rcpp_init.cpp -o Rcpp_init.o llvm-g++-4.2 -arch x86_64 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I../inst/include/ -I/usr/local/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -fPIC -mtune=core2 -g -O2 -c api.cpp -o api.o llvm-g++-4.2 -arch x86_64 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I../inst/include/ -I/usr/local/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -fPIC -mtune=core2 -g -O2 -c attributes.cpp -o attributes.o llvm-g++-4.2 -arch x86_64 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I../inst/include/ -I/usr/local/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -fPIC -mtune=core2 -g -O2 -c barrier.cpp -o barrier.o llvm-g++-4.2 -arch x86_64 -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 -L/usr/local/lib -o Rcpp.so Date.o Module.o Rcpp_init.o api.o attributes.o barrier.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation installing to /Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/libs * R * inst * preparing package for lazy loading * help ** installing help indices * building package indices * installing vignettes * testing if installed package can be loaded
  • DONE (Rcpp)

The downloaded source packages are in ‘/private/var/folders/0x/zkhg5kyd7j3199jkj76v9p340000gn/T/RtmpL3VOAS/downloaded_packages’

source("http://mc-stan.org/rstan/stan.R")

This part is just to check whether it will run and I get an error message saying there is no package called Rstan:

Grab earnings and height data

heights_clean <- read.csv ("height.earnings.csv") earn <- heights_clean$earn height <- heights_clean$height male <- heights_clean$male ed <- heights_clean$ed

N <- length(earn)

Artifically define clusters

cluster <- floor((1:N)/100) + 1 J <- max(cluster) fit <- stan("7b Class.stan", data=list(N=1187, J=J, y=earn, height=height, male=male, edu=ed, cluster=cluster), iter=1000, chains=4) Error in packageDescription("rstan")$Date : $ operator is invalid for atomic vectors In addition: Warning message: In packageDescription("rstan") : no package 'rstan' was found print(fit) Error in print(fit) : object 'fit' not found

bgoodri commented 9 years ago
Error in install.packages : Updating loaded packages

Restart rstudio and then do install_rstan() before doing library(arm) or anything else.

On Sun, Apr 12, 2015 at 6:28 PM, Sofieseidenfaden notifications@github.com wrote:

@bgoodri https://github.com/bgoodri: This took some time. I had to shut down my computer and R studio down a few times. It still doesn't work for me. Here is the whole message I get when I install, run the 'source'-command and try to apply the stan package on a model.

Attached is a picture of the install_rstan and stan in my enviroment! [image: rstan installation] https://cloud.githubusercontent.com/assets/11891892/7107860/29e48c84-e141-11e4-8cf8-e234e09e6809.png

Getting started

setwd("~/Desktop/Columbia /3. Sample Survey and Analysis/R data") getwd() # Let's check that this is the right directory [1] "/Users/sofieseidenfaden/Desktop/Columbia /3. Sample Survey and Analysis/R data" rm(list=ls()) # clears objects in memory library(arm) Indlæser krævet pakke: MASS Indlæser krævet pakke: Matrix Indlæser krævet pakke: lme4 Indlæser krævet pakke: Rcpp

arm (Version 1.7-07, built: 2014-8-27)

Working directory is /Users/sofieseidenfaden/Desktop/Columbia /3. Sample Survey and Analysis/R data

library(foreign)

Install STAN -

https://github.com/stan-dev/rstan/wiki/RStan-Getting-Started

Step 1 - Set numbers of processes to uge

Sys.setenv(MAKEFLAGS = "-j4") system("rm -rf /Library/Frameworks/R.framework/Versions/3.1/Resources/library/00LOCK-rstan")

Step 2 - Run the script

source('http://mc-stan.org/rstan/install.R', echo = TRUE, max.deparse.length = 2000)

install_rstan <- function() {

  • on.exit(Sys.unsetenv("R_MAKEVARS_USER"))
  • on.exit(Sys.unsetenv("R_MAKEVARS_SITE"), add = TRUE)

  • try(remove.packages("rstan"), silent = TRUE)
  • Sys.setenv(R_MAKEVARS_USER = "foobar")
  • Sys.setenv(R_MAKEVARS_SITE = "foobar")
  • install.packages(c("inline", "BH", "RcppEigen"))
  • install.packages("Rcpp", type = "source")
  • library(inline)
  • library(Rcpp)
  • src <- '
  • std::vectorstd::string s;
  • s.push_back("hello");
  • s.push_back("world");
  • return Rcpp::wrap(s);
  • '
  • hellofun <- cxxfunction(body = src, includes = '', plugin = 'Rcpp', verbose = FALSE)
  • test <- try(hellofun())
  • if(inherits(test, "try-error")) stop("hello world failed; ask for help on Rcpp list")

  • options(repos = c(getOption("repos"),
  • rstan = "http://rstan.org/repo/"))
  • install.packages("rstan", type = 'source')
  • library(rstan)
  • set_cppo("fast")
  • if (any(grepl("^darwin", R.version$os, ignore.case = TRUE))) {
  • cat('\nCC=clang', 'CXX=clang++ -arch x86_64 -ftemplate-depth-256',
  • file = "~/.R/Makevars", sep = "\n", append = TRUE)
  • }
  • return(invisible(NULL))
  • } install_rstan() Removing package from ‘/Library/Frameworks/R.framework/Versions/3.1/Resources/library’ (as ‘lib’ is unspecified) Error in remove.packages : there is no package called ‘rstan’ trying URL ' http://cran.rstudio.com/bin/macosx/contrib/3.1/inline_0.3.13.tgz' Content type 'application/x-gzip' length 78503 bytes (76 KB) opened URL ================================================== downloaded 76 KB

    trying URL ' http://cran.rstudio.com/bin/macosx/contrib/3.1/BH_1.55.0-3.tgz' Content type 'application/x-gzip' length 7455235 bytes (7.1 MB) opened URL

downloaded 7.1 MB

trying URL ' http://cran.rstudio.com/bin/macosx/contrib/3.1/RcppEigen_0.3.2.4.0.tgz' Content type 'application/x-gzip' length 3335332 bytes (3.2 MB) opened URL

downloaded 3.2 MB

The downloaded binary packages are in

/var/folders/0x/zkhg5kyd7j3199jkj76v9p340000gn/T//RtmpYD83HK/downloaded_packages Error in install.packages : Updating loaded packages

Attaching package: ‘inline’

The following object is masked from ‘package:Rcpp’:

registerPlugin

Restarting R session...

Warning message: In save(opt, file = filename) : 'package:stats' er måske ikke tilgængelig under indlæsning

install.packages("Rcpp", type = "source") Error in get(name, envir = asNamespace(pkg), inherits = FALSE) : promise already under evaluation: recursive default argument reference or earlier problems? trying URL 'http://cran.rstudio.com/src/contrib/Rcpp_0.11.5.tar.gz' Content type 'application/x-gzip' length 2353791 bytes (2.2 MB) opened URL

downloaded 2.2 MB

  • installing source package ‘Rcpp’ ... * package ‘Rcpp’ successfully unpacked and MD5 sums checked * libs llvm-g++-4.2 -arch x86_64 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I../inst/include/ -I/usr/local/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -fPIC -mtune=core2 -g -O2 -c Date.cpp -o Date.o llvm-g++-4.2 -arch x86_64 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I../inst/include/ -I/usr/local/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -fPIC -mtune=core2 -g -O2 -c Module.cpp -o Module.o llvm-g++-4.2 -arch x86_64 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I../inst/include/ -I/usr/local/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -fPIC -mtune=core2 -g -O2 -c Rcpp_init.cpp -o Rcpp_init.o llvm-g++-4.2 -arch x86_64 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I../inst/include/ -I/usr/local/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -fPIC -mtune=core2 -g -O2 -c api.cpp -o api.o llvm-g++-4.2 -arch x86_64 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I../inst/include/ -I/usr/local/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -fPIC -mtune=core2 -g -O2 -c attributes.cpp -o attributes.o llvm-g++-4.2 -arch x86_64 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I../inst/include/ -I/usr/local/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -fPIC -mtune=core2 -g -O2 -c barrier.cpp -o barrier.o llvm-g++-4.2 -arch x86_64 -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 -L/usr/local/lib -o Rcpp.so Date.o Module.o Rcpp_init.o api.o attributes.o barrier.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation installing to /Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/libs R * inst * preparing package for lazy loading \ help * installing help indices * building package indices * installing vignettes \ testing if installed package can be loaded
  • DONE (Rcpp)

The downloaded source packages are in

‘/private/var/folders/0x/zkhg5kyd7j3199jkj76v9p340000gn/T/RtmpL3VOAS/downloaded_packages’

source("http://mc-stan.org/rstan/stan.R")

This part is just to check whether it will run and I get an error message saying there is no package called Rstan:

Grab earnings and height data

heights_clean <- read.csv ("height.earnings.csv") earn <- heights_clean$earn height <- heights_clean$height male <- heights_clean$male ed <- heights_clean$ed

N <- length(earn) Artifically define clusters

cluster <- floor((1:N)/100) + 1 J <- max(cluster) fit <- stan("7b Class.stan", data=list(N=1187, J=J, y=earn, height=height, male=male, edu=ed, cluster=cluster), iter=1000, chains=4) Error in packageDescription("rstan")$Date : $ operator is invalid for atomic vectors In addition: Warning message: In packageDescription("rstan") : no package 'rstan' was found print(fit) Error in print(fit) : object 'fit' not found

— Reply to this email directly or view it on GitHub https://github.com/stan-dev/rstan/issues/153#issuecomment-92144817.

Sofieseidenfaden commented 9 years ago

@bgoodri: I really appreciate your help!

By restarting Rstudio and do install_rstan() as the first thing I get:

Getting started

setwd("~/Desktop/Columbia /3. Sample Survey and Analysis/R data") getwd() # Let's check that this is the right directory [1] "/Users/sofieseidenfaden/Desktop/Columbia /3. Sample Survey and Analysis/R data" rm(list=ls()) # clears objects in memory

Install STAN - https://github.com/stan-dev/rstan/wiki/RStan-Getting-Started

Step 1 - Set numbers of processes to uge

Sys.setenv(MAKEFLAGS = "-j4") system("rm -rf /Library/Frameworks/R.framework/Versions/3.1/Resources/library")

Step 2 - Run the script

source('http://mc-stan.org/rstan/install.R', echo = TRUE, max.deparse.length = 2000)

install_rstan <- function() {

  • on.exit(Sys.unsetenv("R_MAKEVARS_USER"))
  • on.exit(Sys.unsetenv("R_MAKEVARS_SITE"), add = TRUE)
  • try(remove.packages("rstan"), silent = TRUE)
  • Sys.setenv(R_MAKEVARS_USER = "foobar")
  • Sys.setenv(R_MAKEVARS_SITE = "foobar")
  • install.packages(c("inline", "BH", "RcppEigen"))
  • install.packages("Rcpp", type = "source")
  • library(inline)
  • library(Rcpp)
  • src <- '
  • std::vectorstd::string s;
  • s.push_back("hello");
  • s.push_back("world");
  • return Rcpp::wrap(s);
  • '
  • hellofun <- cxxfunction(body = src, includes = '', plugin = 'Rcpp', verbose = FALSE)
  • test <- try(hellofun())
  • if(inherits(test, "try-error")) stop("hello world failed; ask for help on Rcpp list")
  • options(repos = c(getOption("repos"),
  • rstan = "http://rstan.org/repo/"))
  • install.packages("rstan", type = 'source')
  • library(rstan)
  • set_cppo("fast")
  • if (any(grepl("^darwin", R.version$os, ignore.case = TRUE))) {
  • cat('\nCC=clang', 'CXX=clang++ -arch x86_64 -ftemplate-depth-256',
  • file = "~/.R/Makevars", sep = "\n", append = TRUE)
  • }
  • return(invisible(NULL))
  • } install_rstan() Removing package from ‘/Users/sofieseidenfaden/Library/R/3.1/library’ (as ‘lib’ is unspecified) Fejl i pkgs.name[[i]] : subscript out of bounds Error in remove.packages : Fejl i pkgs.name[[i]] : subscript out of bounds

Warning in install.packages : dependencies ‘methods’, ‘graphics’, ‘grid’, ‘stats’, ‘utils’, ‘grDevices’ are not available also installing the dependencies ‘lattice’, ‘Matrix’, ‘Rcpp’

trying URL 'http://cran.rstudio.com/bin/macosx/contrib/3.1/lattice_0.20-31.tgz' Content type 'application/x-gzip' length 706083 bytes (689 KB)

opened URL

downloaded 689 KB

trying URL 'http://cran.rstudio.com/bin/macosx/contrib/3.1/Matrix_1.2-0.tgz' Content type 'application/x-gzip' length 3502296 bytes (3.3 MB)

opened URL

downloaded 3.3 MB

trying URL 'http://cran.rstudio.com/bin/macosx/contrib/3.1/Rcpp_0.11.5.tgz' Content type 'application/x-gzip' length 2667081 bytes (2.5 MB)

opened URL

downloaded 2.5 MB

trying URL 'http://cran.rstudio.com/bin/macosx/contrib/3.1/inline_0.3.13.tgz' Content type 'application/x-gzip' length 78503 bytes (76 KB)

opened URL

downloaded 76 KB

trying URL 'http://cran.rstudio.com/bin/macosx/contrib/3.1/BH_1.55.0-3.tgz' Content type 'application/x-gzip' length 7455235 bytes (7.1 MB)

opened URL

downloaded 7.1 MB

trying URL 'http://cran.rstudio.com/bin/macosx/contrib/3.1/RcppEigen_0.3.2.4.0.tgz' Content type 'application/x-gzip' length 3335332 bytes (3.2 MB)

opened URL

downloaded 3.2 MB

The downloaded binary packages are in /var/folders/0x/zkhg5kyd7j3199jkj76v9p340000gn/T//Rtmpj8zI3p/downloaded_packages Warning in install.packages : dependency ‘methods’ is not available trying URL 'http://cran.rstudio.com/src/contrib/Rcpp_0.11.5.tar.gz' Content type 'application/x-gzip' length 2353791 bytes (2.2 MB)

opened URL

downloaded 2.2 MB

Fatal error: unable to open the base package

Warning in install.packages : installation of package ‘Rcpp’ had non-zero exit status

The downloaded source packages are in ‘/private/var/folders/0x/zkhg5kyd7j3199jkj76v9p340000gn/T/Rtmpj8zI3p/downloaded_packages’

Attaching package: ‘Rcpp’

The following object is masked from ‘package:inline’:

registerPlugin

Fatal error: unable to open the base package

ERROR(s) during compilation: source code errors or compiler configuration errors!

Program source: 1: 2: // includes from the plugin 3: 4: #include 5: 6: 7: #ifndef BEGIN_RCPP 8: #define BEGIN_RCPP 9: #endif 10: 11: #ifndef END_RCPP 12: #define END_RCPP 13: #endif 14: 15: using namespace Rcpp; 16: 17: 18: // user includes 19: 20: 21: // declarations 22: extern "C" { 23: SEXP file1ed2f1624a6( ) ; 24: } 25: 26: // definition 27: 28: SEXP file1ed2f1624a6( ){ 29: BEGIN_RCPP 30:
31: std::vectorstd::string s; 32: s.push_back("hello"); 33: s.push_back("world"); 34: return Rcpp::wrap(s); 35:
36: END_RCPP 37: } 38: 39: Error in compileCode(f, code, language = language, verbose = verbose) : Compilation ERROR, function(s)/method(s) not created! Fatal error: unable to open the base package In addition: Warning message: running command '/Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB file1ed2f1624a6.cpp 2> file1ed2f1624a6.cpp.err.txt' havde status 2 Called from: cxxfunction(body = src, includes = "", plugin = "Rcpp", verbose = FALSE)

And from the source viewer I get following: function (f, code, language, verbose) { wd = getwd() on.exit(setwd(wd)) if (.Platform$OS.type == "windows") { dir <- gsub("\", "/", tempdir()) libCFile <- paste(dir, "/", f, ".EXT", sep = "") libLFile <- paste(dir, "/", f, ".dll", sep = "") libLFile2 <- paste(dir, "/", f, ".dll", sep = "") } else { libCFile <- paste(tempdir(), "/", f, ".EXT", sep = "") libLFile <- paste(tempdir(), "/", f, .Platform$dynlib.ext, sep = "") libLFile2 <- paste(tempdir(), "/", f, ".sl", sep = "") } extension <- switch(language, C++ = ".cpp", C = ".c", Fortran = ".f", F95 = ".f95", ObjectiveC = ".m", ObjectiveC++ = ".mm") libCFile <- sub(".EXT$", extension, libCFile) write(code, libCFile) if (file.exists(libLFile)) file.remove(libLFile) if (file.exists(libLFile2)) file.remove(libLFile2) setwd(dirname(libCFile)) errfile <- paste(basename(libCFile), ".err.txt", sep = "") cmd <- paste(R.home(component = "bin"), "/R CMD SHLIB ", basename(libCFile), " 2> ", errfile, sep = "") if (verbose) cat("Compilation argument:\n", cmd, "\n") compiled <- system(cmd, intern = !verbose) errmsg <- readLines(errfile) unlink(errfile) writeLines(errmsg) setwd(wd) if (!file.exists(libLFile) && file.exists(libLFile2)) libLFile <- libLFile2 if (!file.exists(libLFile)) { cat("\nERROR(s) during compilation: source code errors or compiler configuration errors!\n") cat("\nProgram source:\n") code <- strsplit(code, "\n") for (i in 1:length(code[[1]])) cat(format(i, width = 3), ": ", code[[1]][i], "\n", sep = "") stop(paste("Compilation ERROR, function(s)/method(s) not created!", paste(errmsg, collapse = "\n"))) } return(libLFile) }

bgoodri commented 9 years ago

The downloaded binary packages are in

/var/folders/0x/zkhg5kyd7j3199jkj76v9p340000gn/T//Rtmpj8zI3p/downloaded_packages Warning in install.packages : dependency ‘methods’ is not available

Somehow you don't have the methods package available, which is supposed to come with R. Maybe it is there but in a folder that can't be found. Or maybe R did not install correctly. Anyway, you have to fix that before Rcpp can install.

trying URL 'http://cran.rstudio.com/src/contrib/Rcpp_0.11.5.tar.gz' Content type 'application/x-gzip' length 2353791 bytes (2.2 MB)

opened URL

downloaded 2.2 MB

Fatal error: unable to open the base package

Warning in install.packages : installation of package ‘Rcpp’ had non-zero exit status

The downloaded source packages are in

‘/private/var/folders/0x/zkhg5kyd7j3199jkj76v9p340000gn/T/Rtmpj8zI3p/downloaded_packages’

Attaching package: ‘Rcpp’

The following object is masked from ‘package:inline’:

registerPlugin

Fatal error: unable to open the base package

ERROR(s) during compilation: source code errors or compiler configuration errors!

Program source: 1: 2: // includes from the plugin 3: 4: #include 5: 6: 7: #ifndef BEGIN_RCPP 8: #define BEGIN_RCPP 9: #endif 10: 11: #ifndef END_RCPP 12: #define END_RCPP 13: #endif 14: 15: using namespace Rcpp; 16: 17: 18: // user includes 19: 20: 21: // declarations 22: extern "C" { 23: SEXP file1ed2f1624a6( ) ; 24: } 25: 26: // definition 27: 28: SEXP file1ed2f1624a6( ){ 29: BEGIN_RCPP 30:

31: std::vectorstd::string s; 32: s.push_back("hello"); 33: s.push_back("world"); 34: return Rcpp::wrap(s); 35:

36: END_RCPP 37: } 38: 39: Error in compileCode(f, code, language = language, verbose = verbose) : Compilation ERROR, function(s)/method(s) not created! Fatal error: unable to open the base package In addition: Warning message: running command '/Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB file1ed2f1624a6.cpp 2> file1ed2f1624a6.cpp.err.txt' havde status 2 Called from: cxxfunction(body = src, includes = "", plugin = "Rcpp", verbose = FALSE)

And from the source viewer I get following: function (f, code, language, verbose) { wd = getwd() on.exit(setwd(wd)) if (.Platform$OS.type == "windows") { dir <- gsub("\", "/", tempdir()) libCFile <- paste(dir, "/", f, ".EXT", sep = "") libLFile <- paste(dir, "/", f, ".dll", sep = "") libLFile2 <- paste(dir, "/", f, ".dll", sep = "") } else { libCFile <- paste(tempdir(), "/", f, ".EXT", sep = "") libLFile <- paste(tempdir(), "/", f, .Platform$dynlib.ext, sep = "") libLFile2 <- paste(tempdir(), "/", f, ".sl", sep = "") } extension <- switch(language, C++ = ".cpp", C = ".c", Fortran = ".f", F95 = ".f95", ObjectiveC = ".m", ObjectiveC++ = ".mm") libCFile <- sub(".EXT$", extension, libCFile) write(code, libCFile) if (file.exists(libLFile)) file.remove(libLFile) if (file.exists(libLFile2)) file.remove(libLFile2) setwd(dirname(libCFile)) errfile <- paste(basename(libCFile), ".err.txt", sep = "") cmd <- paste(R.home(component = "bin"), "/R CMD SHLIB ", basename(libCFile), " 2> ", errfile, sep = "") if (verbose) cat("Compilation argument:\n", cmd, "\n") compiled <- system(cmd, intern = !verbose) errmsg <- readLines(errfile) unlink(errfile) writeLines(errmsg) setwd(wd) if (!file.exists(libLFile) && file.exists(libLFile2)) libLFile <- libLFile2 if (!file.exists(libLFile)) { cat("\nERROR(s) during compilation: source code errors or compiler configuration errors!\n") cat("\nProgram source:\n") code <- strsplit(code, "\n") for (i in 1:length(code[[1]])) cat(format(i, width = 3), ": ", code[[1]][i], "\n", sep = "") stop(paste("Compilation ERROR, function(s)/method(s) not created!",

Sofieseidenfaden commented 9 years ago

@bgoodri! Thank you for your help - it is eventually been installed. Robert Trangucci helped me!

rtrangucci commented 9 years ago

Thanks Sofie, glad we could get you all set up.

The problem ended up being the 00LOCK-rstan file again, though it had moved. Apparently it isn't always guaranteed to be here: /Library/Frameworks/R.framework/Versions/3.1/Resources/library/

R will tell you where the file is located so Ben's suggestion of removing from R works fine as long as the path to the 00LOCK-rstan file is correct.

system("rm -rf /Path/to/00LOCK-rstan")

Rob

On Mon, Apr 13, 2015 at 4:23 PM, Sofieseidenfaden notifications@github.com wrote:

@bgoodri https://github.com/bgoodri! Thank you for your help - it is eventually been installed. Robert Trangucci helped me!

— Reply to this email directly or view it on GitHub https://github.com/stan-dev/rstan/issues/153#issuecomment-92487892.