I’ve successfully installed RStan and have fit models using the stan() function. However, I recently upgraded both my OS (OSX 10.15.3 Catalina) and R (3.6.2). Now, while I can successfully load rstan with library(rstan), I get an error when I run the stan() function:
Error in dyn.load(libLFile) :
unable to load shared object ‘/var/folders/gq/9syhh2254tj34hcvb_rdplvm0000gn/T//RtmpBRndMU/file20241478ff9d.so’:
dlopen(/var/folders/gq/9syhh2254tj34hcvb_rdplvm0000gn/T//RtmpBRndMU/file20241478ff9d.so, 6): Library not loaded: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libR.dylib
Referenced from: /private/var/folders/gq/9syhh2254tj34hcvb_rdplvm0000gn/T/RtmpBRndMU/file20241478ff9d.so
Reason: image not found
I’ve tried uninstalling and reinstalling rstan as well as R, but continue to get this error. Would appreciate any suggestions!
Hm. I’ve just tried this, and I’m still having the issue. When I run the second line installing rstan from source, I get the following error:
Warning in install.packages : installation of package ‘rstan’ had non-zero exit status
installing source package ‘Rcpp’ …
** using staged installation
** libs
clang++ -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I…/inst/include/ -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include -include /Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp -I /Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include -I /Library/Frameworks/R.framework/Versions/3.6/Resources/library/RcppEigen/include -include /Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp -I /Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include -I /Library/Frameworks/R.framework/Versions/3.6/Resources/library/RcppEigen/include -fPIC -Wall -g -O2 -c api.cpp -o api.o
In file included from :1:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:13:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/RcppEigen/include/Eigen/Dense:1:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/RcppEigen/include/Eigen/Core:436:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/RcppEigen/include/Eigen/src/Core/MatrixBase.h:130:
/Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/stan/math/prim/mat/eigen_plugins.h:22:25: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using double_return_t = std::conditional_t<std::is_const<std::remove_reference_t>::value,
^
/Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/stan/math/prim/mat/eigen_plugins.h:22:30: error: no template named ‘conditional_t’ in namespace ‘std’; did you mean ‘conditional’?
using double_return_t = std::conditional_t<std::is_const<std::remove_reference_t>::value,
~^~~~~~~~~
conditional
/Library/Developer/CommandLineTools/usr/bin/…/include/c++/v1/type_traits:440:33: note: ‘conditional’ declared here
struct _LIBCPP_TEMPLATE_VIS conditional {typedef _If type;};
^
In file included from :1:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:13:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/RcppEigen/include/Eigen/Dense:1:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/RcppEigen/include/Eigen/Core:436:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/RcppEigen/include/Eigen/src/Core/MatrixBase.h:130:
/Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/stan/math/prim/mat/eigen_plugins.h:22:63: error: no template named ‘remove_reference_t’ in namespace ‘std’; did you mean ‘remove_reference’?
using double_return_t = std::conditional_t<std::is_const<std::remove_reference_t>::value,
~^~~~~~~~~~~~~~
remove_reference
/Library/Developer/CommandLineTools/usr/bin/…/include/c++/v1/type_traits:1131:50: note: ‘remove_reference’ declared here
template struct _LIBCPP_TEMPLATE_VIS remove_reference {typedef _LIBCPP_NODEBUG_TYPE _Tp type;};
^
In file included from :1:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:13:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/RcppEigen/include/Eigen/Dense:1:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/RcppEigen/include/Eigen/Core:436:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/RcppEigen/include/Eigen/src/Core/MatrixBase.h:130:
/Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/stan/math/prim/mat/eigen_plugins.h:22:83: error: a space is required between consecutive right angle brackets (use ‘> >’)
using double_return_t = std::conditional_t<std::is_const<std::remove_reference_t>::value,
^~
> >
/Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/stan/math/prim/mat/eigen_plugins.h:26:26: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using reverse_return_t = std::conditional_t<std::is_const<std::remove_reference_t>::value,
^
/Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/stan/math/prim/mat/eigen_plugins.h:26:31: error: no template named ‘conditional_t’ in namespace ‘std’; did you mean ‘conditional’?
using reverse_return_t = std::conditional_t<std::is_const<std::remove_reference_t>::value,
~^~~~~~~~~
conditional
/Library/Developer/CommandLineTools/usr/bin/…/include/c++/v1/type_traits:440:33: note: ‘conditional’ declared here
struct _LIBCPP_TEMPLATE_VIS conditional {typedef _If type;};
^
In file included from :1:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:13:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/RcppEigen/include/Eigen/Dense:1:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/RcppEigen/include/Eigen/Core:436:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/RcppEigen/include/Eigen/src/Core/MatrixBase.h:130:
/Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/stan/math/prim/mat/eigen_plugins.h:26:64: error: no template named ‘remove_reference_t’ in namespace ‘std’; did you mean ‘remove_reference’?
using reverse_return_t = std::conditional_t<std::is_const<std::remove_reference_t>::value,
~^~~~~~~~~~~~~~
remove_reference
/Library/Developer/CommandLineTools/usr/bin/…/include/c++/v1/type_traits:1131:50: note: ‘remove_reference’ declared here
template struct _LIBCPP_TEMPLATE_VIS remove_reference {typedef _LIBCPP_NODEBUG_TYPE _Tp type;};
^
In file included from :1:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:13:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/RcppEigen/include/Eigen/Dense:1:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/RcppEigen/include/Eigen/Core:436:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/RcppEigen/include/Eigen/src/Core/MatrixBase.h:130:
/Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/stan/math/prim/mat/eigen_plugins.h:26:84: error: a space is required between consecutive right angle brackets (use ‘> >’)
using reverse_return_t = std::conditional_t<std::is_const<std::remove_reference_t>::value,
^~
> >
/Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/stan/math/prim/mat/eigen_plugins.h:31:23: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using vari_return_t = std::conditional_t<std::is_const<std::remove_reference_t>::value,
^
/Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/stan/math/prim/mat/eigen_plugins.h:31:28: error: no template named ‘conditional_t’ in namespace ‘std’; did you mean ‘conditional’?
using vari_return_t = std::conditional_t<std::is_const<std::remove_reference_t>::value,
~^~~~~~~~~
conditional
/Library/Developer/CommandLineTools/usr/bin/…/include/c++/v1/type_traits:440:33: note: ‘conditional’ declared here
struct _LIBCPP_TEMPLATE_VIS conditional {typedef _If type;};
^
In file included from :1:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:13:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/RcppEigen/include/Eigen/Dense:1:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/RcppEigen/include/Eigen/Core:436:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/RcppEigen/include/Eigen/src/Core/MatrixBase.h:130:
/Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/stan/math/prim/mat/eigen_plugins.h:31:61: error: no template named ‘remove_reference_t’ in namespace ‘std’; did you mean ‘remove_reference’?
using vari_return_t = std::conditional_t<std::is_const<std::remove_reference_t>::value,
~^~~~~~~~~~~~~~
remove_reference
/Library/Developer/CommandLineTools/usr/bin/…/include/c++/v1/type_traits:1131:50: note: ‘remove_reference’ declared here
template struct _LIBCPP_TEMPLATE_VIS remove_reference {typedef _LIBCPP_NODEBUG_TYPE _Tp type;};
^
In file included from :1:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:13:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/RcppEigen/include/Eigen/Dense:1:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/RcppEigen/include/Eigen/Core:436:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/RcppEigen/include/Eigen/src/Core/MatrixBase.h:130:
/Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/stan/math/prim/mat/eigen_plugins.h:31:81: error: a space is required between consecutive right angle brackets (use ‘> >’)
using vari_return_t = std::conditional_t<std::is_const<std::remove_reference_t>::value,
^~
> >
/Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/stan/math/prim/mat/eigen_plugins.h:36:26: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using forward_return_t = std::conditional_t<std::is_const<std::remove_reference_t>::value,
^
/Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/stan/math/prim/mat/eigen_plugins.h:36:31: error: no template named ‘conditional_t’ in namespace ‘std’; did you mean ‘conditional’?
using forward_return_t = std::conditional_t<std::is_const<std::remove_reference_t>::value,
~^~~~~~~~~
conditional
/Library/Developer/CommandLineTools/usr/bin/…/include/c++/v1/type_traits:440:33: note: ‘conditional’ declared here
struct _LIBCPP_TEMPLATE_VIS conditional {typedef _If type;};
^
In file included from :1:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:13:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/RcppEigen/include/Eigen/Dense:1:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/RcppEigen/include/Eigen/Core:436:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/RcppEigen/include/Eigen/src/Core/MatrixBase.h:130:
/Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/stan/math/prim/mat/eigen_plugins.h:36:64: error: no template named ‘remove_reference_t’ in namespace ‘std’; did you mean ‘remove_reference’?
using forward_return_t = std::conditional_t<std::is_const<std::remove_reference_t>::value,
~^~~~~~~~~~~~~~
remove_reference
/Library/Developer/CommandLineTools/usr/bin/…/include/c++/v1/type_traits:1131:50: note: ‘remove_reference’ declared here
template struct _LIBCPP_TEMPLATE_VIS remove_reference {typedef _LIBCPP_NODEBUG_TYPE _Tp type;};
^
In file included from :1:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:13:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/RcppEigen/include/Eigen/Dense:1:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/RcppEigen/include/Eigen/Core:436:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/RcppEigen/include/Eigen/src/Core/MatrixBase.h:130:
/Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/stan/math/prim/mat/eigen_plugins.h:36:84: error: a space is required between consecutive right angle brackets (use ‘> >’)
using forward_return_t = std::conditional_t<std::is_const<std::remove_reference_t>::value,
^~
> >
/Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/stan/math/prim/mat/eigen_plugins.h:60:10: error: no template named ‘enable_if_t’ in namespace ‘std’; did you mean ‘enable_if’?
std::enable_if_t<std::is_pointer::value, reverse_return_t>
enable_if
/Library/Developer/CommandLineTools/usr/bin/…/include/c++/v1/type_traits:451:63: note: ‘enable_if’ declared here
template <bool, class _Tp = void> struct _LIBCPP_TEMPLATE_VIS enable_if {};
^
In file included from :1:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:13:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/RcppEigen/include/Eigen/Dense:1:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/RcppEigen/include/Eigen/Core:436:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/RcppEigen/include/Eigen/src/Core/MatrixBase.h:130:
/Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/stan/math/prim/mat/eigen_plugins.h:60:67: error: a space is required between consecutive right angle brackets (use ‘> >’)
std::enable_if_t<std::is_pointer::value, reverse_return_t>
^~
> >
/Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/stan/math/prim/mat/eigen_plugins.h:58:21: warning: default template arguments for a function template are a C++11 extension [-Wc++11-extensions]
template
^ ~~~~~~
/Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/stan/math/prim/mat/eigen_plugins.h:66:10: error: no template named ‘enable_if_t’ in namespace ‘std’; did you mean ‘enable_if’?
std::enable_if_t<(!std::is_pointer::value && !is_fvar::value
~^~~~~~~
enable_if
/Library/Developer/CommandLineTools/usr/bin/…/include/c++/v1/type_traits:451:63: note: ‘enable_if’ declared here
template <bool, class _Tp = void> struct _LIBCPP_TEMPLATE_VIS enable_if {};
^
In file included from :1:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:13:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/RcppEigen/include/Eigen/Dense:1:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/RcppEigen/include/Eigen/Core:436:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/RcppEigen/include/Eigen/src/Core/MatrixBase.h:130:
/Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/stan/math/prim/mat/eigen_plugins.h:67:76: error: a space is required between consecutive right angle brackets (use ‘> >’)
&& !std::is_arithmetic::value), reverse_return_t>
^~
> >
/Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/stan/math/prim/mat/eigen_plugins.h:64:21: warning: default template arguments for a function template are a C++11 extension [-Wc++11-extensions]
template
^ ~~~~~~
/Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/stan/math/prim/mat/eigen_plugins.h:73:10: error: no template named ‘enable_if_t’ in namespace ‘std’; did you mean ‘enable_if’?
std::enable_if_t<is_fvar::value, forward_return_t>
~^~~~~~~
enable_if
/Library/Developer/CommandLineTools/usr/bin/…/include/c++/v1/type_traits:451:63: note: ‘enable_if’ declared here
template <bool, class _Tp = void> struct _LIBCPP_TEMPLATE_VIS enable_if {};
^
In file included from :1:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:13:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/RcppEigen/include/Eigen/Dense:1:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/RcppEigen/include/Eigen/Core:436:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/RcppEigen/include/Eigen/src/Core/MatrixBase.h:130:
/Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/stan/math/prim/mat/eigen_plugins.h:73:59: error: a space is required between consecutive right angle brackets (use ‘> >’)
std::enable_if_t<is_fvar::value, forward_return_t>
^~
> >
/Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/stan/math/prim/mat/eigen_plugins.h:71:21: warning: default template arguments for a function template are a C++11 extension [-Wc++11-extensions]
template
^ ~~~~~~
/Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/stan/math/prim/mat/eigen_plugins.h:79:10: error: no template named ‘enable_if_t’ in namespace ‘std’; did you mean ‘enable_if’?
std::enable_if_t<std::is_arithmetic::value, double_return_t>
~^~~~~~~
enable_if
/Library/Developer/CommandLineTools/usr/bin/…/include/c++/v1/type_traits:451:63: note: ‘enable_if’ declared here
template <bool, class _Tp = void> struct _LIBCPP_TEMPLATE_VIS enable_if {};
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
7 warnings and 20 errors generated.
make: *** [api.o] Error 1
ERROR: compilation failed for package ‘Rcpp’
restoring previous ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/Rcpp’
Warning in install.packages :
installation of package ‘Rcpp’ had non-zero exit status
@bgoodri That seems to have worked fine, installed with no errors. I was also able to download the Rcpp drat using: install.packages("drat", repos="http://cran.rstudio.com")
and rstan seems to have installed just fine as well: install.packages("rstan", type = "source")
installing to /Library/Frameworks/R.framework/Versions/3.6/Resources/library/00LOCK-rstan/00new/rstan/libs
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
*** copying figures
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
** checking absolute paths in shared objects and dynamic libraries
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
DONE (rstan)
The downloaded source packages are in
‘/private/var/folders/gq/9syhh2254tj34hcvb_rdplvm0000gn/T/RtmpiGqyzi/downloaded_packages’
However, I still get the error when running the stan() function:
Error in dyn.load(libLFile) :
unable to load shared object ‘/var/folders/gq/9syhh2254tj34hcvb_rdplvm0000gn/T//RtmpiGqyzi/file2d6328fd3f5b.so’:
dlopen(/var/folders/gq/9syhh2254tj34hcvb_rdplvm0000gn/T//RtmpiGqyzi/file2d6328fd3f5b.so, 6): Library not loaded: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libR.dylib
Referenced from: /private/var/folders/gq/9syhh2254tj34hcvb_rdplvm0000gn/T/RtmpiGqyzi/file2d6328fd3f5b.so
Reason: image not found
I’ve done so, but unfortunately this still hasn’t solved the problem. :(
I can see that I only have 3.6 now:
drwxrwxr-x 6 root admin 192 Apr 5 17:09 3.6
lrwxr-xr-x 1 root admin 3 Apr 5 17:09 Current -> 3.6
When I run .libPaths(), I get:
“/Library/Frameworks/R.framework/Versions/3.6/Resources/library”
When I go to /Library/Frameworks/R.framework/Versions/, I only see two folders: 3.6 and Current. But still, I get the same error when trying to run the stan() function, even after reinstalling rstan and Rcpp.
Hi - I know this post is a year old at this point, but I’m wondering if you ever solved this issue? I’m having the exact same issue, but with R 4.1 vs 4.0 (whereas you were facing this issue for R 3.6 vs 3.5).
Specifically, I can install Rcpp and rstan just fine, but when I run stan() I get the following error:
Error in dyn.load(libLFile) :
unable to load shared object ‘/var/folders/zc/z9sq_vps0bj8kf6w4j76yd7w0000gn/T//Rtmps4znDq/file1146c4fb3cf22.so’:
dlopen(/var/folders/zc/z9sq_vps0bj8kf6w4j76yd7w0000gn/T//Rtmps4znDq/file1146c4fb3cf22.so, 6): Library not loaded: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libR.dylib
Referenced from: /private/var/folders/zc/z9sq_vps0bj8kf6w4j76yd7w0000gn/T/Rtmps4znDq/file1146c4fb3cf22.so
Reason: image not found
Exactly the same as you, I completely removed R 4.0, but still get this error. I’ve gone to the point of completely uninstalling R from my computer, and only installing R 4.1, but I still get this same error. Does anyone have suggestions on how to move forward?