RStan 不工作,失败:clang++ -mmacosx-version-min=10.13: command not found
RStan not working, failing with: clang++ -mmacosx-version-min=10.13: command not found
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
>
这花了一段时间,但我弄明白了。为后人发帖。
事实证明,Rstan 与 Big Sur 有问题。最好安装开发人员版本,如下所示:https://github.com/stan-dev/stanc3/issues/795
卸载 RStan
重启 R 内核
运行
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
这解决了我所有的问题!
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
>
这花了一段时间,但我弄明白了。为后人发帖。
事实证明,Rstan 与 Big Sur 有问题。最好安装开发人员版本,如下所示:https://github.com/stan-dev/stanc3/issues/795
卸载 RStan
重启 R 内核
运行
remotes::install_github("stan-dev/rstan", ref = "develop", subdir = "rstan/rstan")
这可能会引发 cmath 问题。在较高级别上,覆盖
替换:
#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
这解决了我所有的问题!