Able to load rstan, but unable to run stan() funciton

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!

Go through the first and last posts at

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

That is not good. Can you post more of the error message when you try to install rstan?

I managed to resolve that issue – just needed to reinstall command line developer tools. However, now I’m having issues installing Rcpp from drat:
Warning in install.packages :
unable to access index for repository https://rcppcore.github.io/drat/bin/macosx/el-capitan/contrib/3.6:
cannot open URL ‘https://rcppcore.github.io/drat/bin/macosx/el-capitan/contrib/3.6/PACKAGES

Does

install.packages("Rcpp", repos="https://RcppCore.github.io/drat", 
                 type = "source")

work?

Unfortunately no, compilation is still failing.


trying URL ‘https://RcppCore.github.io/drat/src/contrib/Rcpp_1.0.4.6.tar.gz
Content type ‘application/gzip’ length 2711228 bytes (2.6 MB)

downloaded 2.6 MB

  • 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’

  • removing ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/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

@coatless Did something change with the Rcpp drat?

@bgoodri Dirk just uploaded Rcpp 1.0.4.6.

http://lists.r-forge.r-project.org/pipermail/rcpp-devel/2020-April/010434.html

I’m not sure what’s going on with this compiler trace.

@blake can type into R:

sessionInfo()

Here’s what I get:
R version 3.6.2 (2019-12-12)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Catalina 10.15.3

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.6/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_3.6.2 assertthat_0.2.1 cli_2.0.2 tools_3.6.2 glue_1.3.2 rstudioapi_0.11 crayon_1.3.4
[8] fansi_0.4.1

@bgoodri should I try pulling from a different repo?

First, try

install.packages("StanHeaders", type = "source")

@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

Does

file.exists("/Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libR.dylib")

return TRUE or FALSE?

That returns FALSE, but file.exists("/Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libR.dylib")
returns TRUE

Do you have both R 3.5.x and 3.6.x installed?

Yes, it looks like I do. Do you think that’s causing the problem?

ls -l /Library/Frameworks/R.framework/Versions/
total 0
drwxrwxr-x 6 root admin 192 Jul 7 2015 3.2
drwxrwxr-x 3 root admin 96 Mar 15 20:04 3.5
drwxrwxr-x 6 root admin 192 Mar 15 20:26 3.6
lrwxr-xr-x 1 root admin 3 Mar 15 20:26 Current -> 3.6

Yeah, unfortunately. I would totally remove R 3.5.x.

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.

1 Like

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?