【问题标题】:RStan not working, failing with: clang++ -mmacosx-version-min=10.13: command not foundRStan 不工作,失败:clang++ -mmacosx-version-min=10.13: command not found
【发布时间】:2021-06-17 10:54:39
【问题描述】:
library(rstan)
stan_nb <- rstan::stan_model("mything.stan")

我正在运行上面的代码,但在第二行它失败了,抛出(下面的)错误消息和一个弹出窗口说要安装 xcode 开发工具。

DID 安装了 xcode 开发者工具(我已经多次这样做了)。我安装了 R 版本 3.6.3 和 RStudio-1.4.1106.dmg。我有 xquarts 并正在运行 Mac OS X Big Sur 11.2.3 并且还安装了 gfortran 编译器。

关于如何解决这个问题的任何想法?不知道此时该做什么。网上有很多信息,如果有人最近遇到过这个问题并知道解决方案,那将会很有帮助。

R version 4.0.4 (2021-02-15) -- "Lost Library Book"
Copyright (C) 2021 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin17.0 (64-bit)
 
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
 
  Natural language support but running in an English locale
 
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
 
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
 
> library(rstan)
Loading required package: StanHeaders
Loading required package: ggplot2
rstan (Version 2.21.1, 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)
> options(mc.cores = parallel::detectCores())
> library(rstan)
> stan_nb <- rstan::stan_model("mything.stan")
sh: clang++ -mmacosx-version-min=10.13: command not found
The NEXT version of Stan will not be able to pre-process your Stan program.
Please open an issue at
 https://github.com/stan-dev/stanc3/issues 
if you can share or at least describe your Stan program. This will help ensure that Stan
continues to work on your Stan programs in the future. Thank you!
This message can be avoided by wrapping your function call inside suppressMessages().
make cmd is
  make -f '/Library/Frameworks/R.framework/Resources/etc/Makeconf' -f '/Library/Frameworks/R.framework/Resources/share/make/shlib.mk' -f '/Users/bb/.R/Makevars' CXX='$(CXX14) $(CXX14STD)' CXXFLAGS='$(CXX14FLAGS)' CXXPICFLAGS='$(CXX14PICFLAGS)' SHLIB_LDFLAGS='$(SHLIB_CXX14LDFLAGS)' SHLIB_LD='$(SHLIB_CXX14LD)' SHLIB='file4f038d74992.so' OBJECTS='file4f038d74992.o'
 
make would use
clang++ -mmacosx-version-min=10.13 -std=gnu++14 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include/"  -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/"  -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/unsupported"  -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/BH/include" -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/src/"  -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/"  -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppParallel/include/"  -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/rstan/include" -DEIGEN_NO_DEBUG  -DBOOST_DISABLE_ASSERTS  -DBOOST_PENDING_INTEGER_LOG2_HPP  -DSTAN_THREADS  -DBOOST_NO_AUTO_PTR  -include '/Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp'  -D_REENTRANT -DRCPP_PARALLEL_USE_TBB=1   -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include   -fPIC  -Wall -g -O2  -c file4f038d74992.cpp -o file4f038d74992.o
if test  "zfile4f038d74992.o" != "z"; then \
      echo clang++ -mmacosx-version-min=10.13 -std=gnu++14 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -Wl,-rpath,/Library/Frameworks/R.framework/Resources/lib /Library/Frameworks/R.framework/Resources/lib/libc++abi.1.dylib -L"/Library/Frameworks/R.framework/Resources/lib" -L/usr/local/lib -o file4f038d74992.so file4f038d74992.o  /Library/Frameworks/R.framework/Versions/4.0/Resources/library/rstan/lib//libStanServices.a -L'/Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/lib/' -lStanHeaders -L'/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppParallel/lib/' -ltbb -ltbbmalloc -ltbbmalloc_proxy  -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation; \
      clang++ -mmacosx-version-min=10.13 -std=gnu++14 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -Wl,-rpath,/Library/Frameworks/R.framework/Resources/lib /Library/Frameworks/R.framework/Resources/lib/libc++abi.1.dylib -L"/Library/Frameworks/R.framework/Resources/lib" -L/usr/local/lib -o file4f038d74992.so file4f038d74992.o  /Library/Frameworks/R.framework/Versions/4.0/Resources/library/rstan/lib//libStanServices.a -L'/Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/lib/' -lStanHeaders -L'/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppParallel/lib/' -ltbb -ltbbmalloc -ltbbmalloc_proxy  -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation; \
    fi
Error in compileCode(f, code, language = language, verbose = verbose) : 
  /Library/Frameworks/R.framework/Versions/4.0/Resources/library/BH/include/boost/math/special_functions/math_fwd.hpp:879:9: note: 'isfinite' declared here   bool isfinite BOOST_NO_MACRO_EXPAND(T z);        ^fatal error: too many errors emitted, stopping now [-ferror-limit=]15 warnings and 20 errors generated.make: *** [file4f038d74992.o] Error 1
In addition: Warning messages:
1: In system2(CXX, args = ARGS) : error in running command
2: In file.remove(c(unprocessed, processed)) :
  cannot remove file '/var/folders/cj/4rp2qqj549vc48lqqvkzsjtr0000gn/T//RtmpN0DoWO/file4f062d5a916.stan', reason 'No such file or directory'
Error in sink(type = "output") : invalid connection
> 

【问题讨论】:

    标签: r xcode clang++ rstan


    【解决方案1】:

    这需要一段时间,但我想通了。为了以后的缘故发帖。

    事实证明,Rstan 与 Big Sur 存在问题。最好安装这里所示的开发者版本:https://github.com/stan-dev/stanc3/issues/795

    1. 卸载 RStan

    2. 重启 R 内核

    3. 运行

      remotes::install_github("stan-dev/rstan", ref = "develop", subdir = "rstan/rstan")

    这可能会给 cmath 带来问题。概括地说,覆盖 存在问题。解决方法在这里:Catalina C++: Using <cmath> headers yield error: no member named 'signbit' in the global namespace

    替换:

    #include</Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/math.h> 
    

     <math.h> 
    

    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath
    

    这解决了我所有的问题!

    【讨论】:

      猜你喜欢
      • 2016-07-09
      • 1970-01-01
      • 2021-06-27
      • 2016-01-06
      • 2011-02-12
      • 1970-01-01
      • 2014-10-10
      • 2019-07-01
      • 2019-07-07
      相关资源
      最近更新 更多