readLines("~/.Renviron")
Error in file(con, “r”) : cannot open the connection
In addition: Warning message:
In file(con, “r”) :
cannot open file ‘/Users/jdsal/.Renviron’: No such file or directory
and running the schools example model just hangs for ~6 hrs?
That’s pretty strange! I don’t think I’ve seen that before, although I’ve seen a few people report issues with Mojave. One thing to try is reinstalling Rcpp from source and then, if necessary, also reinstalling RStan from source again after installing Rcpp from source:
install.packages("Rcpp", type = "source")
# try running model again, if same issue then
install.packages("rstan", type = "source")
And if that gets it working then I recommend creating a Makevars file:
# create the file
file.create(file.path(Sys.getenv("HOME"), ".R", "Makevars"))
# open the file for editing
file.edit(file.path(Sys.getenv("HOME"), ".R", "Makevars"))
Jonah, hi there. Thanks for coming on board the thread.
The fresh install of Rcpp from source, then trying the model, yielded the same result as before- the model appears stuck. And, the fresh install of Rcpp then rstan from source, yielded the same as well.
A couple points maybe relevant. First, I’m experiencing these identical problems on two machines that I’m troubleshooting in parallel, both with new R 4.0.2 installed, one running OSX 10.13.6 High Sierra and the other 10.14.6 Mojave.
Second, perhaps relevant, even after quitting out of the R console, the processes continue to run in the background, or at least separate R processes continue to suck up CPU space shown on the system activity monitor.
Yeah, we used to have a lot of trouble with the newer OS X Catalina, but now it’s the opposite and Catalina seems to be fine and the older Mac OSes seem to result in more issues. Often installing Rcpp and RStan from source fixes the issue, but if that didn’t fix it for you then I’m not sure what else to try. If we can’t figure this out soon but you want to run Stan models from R then another option is to try the new CmdStanR interface.
But @bgoodri might have more suggestions. Ben have you seen this before? Any ideas? Here’s a summary:
And installing Rcpp and then RStan from source didn’t fix the problem.
Hey, thanks for chiming in! The below model has been ‘running’ and appears stuck, as before. In the interest of being verbose, I’m including the whole process.
> remotes::install_github("bgoodri/inline")
Downloading GitHub repo bgoodri/inline@HEAD
─ preparing ‘inline’:/private/var/folders/h1/rq6w0dz12pbc3lpb129lhlhh0000gn/T/Rtmp6yGZDy/remotes16ec822742797/bgoodri-inline-f80c7f9/DESCRIPTION’ ...
─ installing the package to process help pages
es
* installing *source* package ‘inline’ ...
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded from temporary location
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (inline)
> library(rstan)
Loading required package: StanHeaders
Loading required package: ggplot2
rstan (Version 2.21.2, 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)
>
> model <-
+ "data {
+ int<lower=0> J;
+ real y[J];
+ real<lower=0> sigma[J];
+ }
+ parameters {
+ real mu;
+ real<lower=0> tau;
+ vector[J] eta;
+ }
+ transformed parameters {
+ vector[J] theta = mu + tau * eta;
+ }
+ model {
+ target += normal_lpdf(eta | 0, 1);
+ target += normal_lpdf(y | theta, sigma);
+ }"
>
> schools_dat <- list(J = 8,
+ y = c(28, 8, -3, 7, -1, 1, 18, 12),
+ sigma = c(15, 10, 16, 11, 9, 11, 10, 18))
> fit <- stan(model_code=model, data = schools_dat, verbose=T)
TRANSLATING MODEL 'c6e5b88b131a8ef63e73c683a2589167' FROM Stan CODE TO C++ CODE NOW.
successful in parsing the Stan model 'c6e5b88b131a8ef63e73c683a2589167'.
OK. This is probably an issue with your toolchain, rather than something specific to Stan. @coatless might have previously encountered someone with this hanging under
R 4.0.2
Mac OS X Mojave or High Sierra
No Makevars file
No Renviron file
Fresh install of the latest RStan
Thanks much. I’m reporting outputs here from a machine running Mohave, but I get the same behavior on a different machine I just upgraded to Catalina (and did a fresh R and RStan install on).
> sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Mojave 10.14.6
Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRblas.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_4.0.2 tools_4.0.2 Rcpp_1.0.5
>
And,
> cat(readLines(file.path(Sys.getenv("HOME"), ".R", "Makevars")), sep = "\n")
Error in file(con, "r") : cannot open the connection
In addition: Warning message:
In file(con, "r") :
cannot open file '/Users/jdsal/.R/Makevars': No such file or directory
>
Then following
update.packages(ask = FALSE, checkBuilt = TRUE)
I get the same hanging behavior as described above if I run the schools example.
I really appreciate the help. I updated to Catalina (10.15.6). I followed this Reinstall compiler tools for MacOS. hellowworld.cpp worked, but the schools example caused the same hanging.
Hi folks. I gave up on this thread back in September, without solving the hanging problem. Ended up reverting to R v3.6x to get work done.
I recently upgraded to R 4.1.0 for a few reasons, and with fresh updates and installs of Rccp, RStan, and CLI. Hopefully revisiting this again someone can help. Here’s the session info: