[英]Mac OS - m1: Can't install ruby 2.7.5 because of an error from configure
I need to install ruby 2.7.5 for my react native app but I can't install 2.7.5 through rvm.我需要为我的本机反应应用程序安装 ruby 2.7.5,但我无法通过 rvm 安装 2.7.5。 I tried many things to install any ruby version, I ended up to get this configure error.
我尝试了很多东西来安装任何 ruby 版本,我最终得到了这个配置错误。
Error running './configure --prefix=/Users/myname/.rvm/rubies/ruby-2.1.1 --disable-install-doc --enable-shared',
please read /Users/myname/.rvm/log/1672107647_ruby-2.1.1/configure.log
There has been an error while running configure. Halting the installation.
Here is the configure log这是配置日志
configure: WARNING: you should use --build, --host, --target
checking for ruby... /usr/bin/ruby
tool/config.guess already exists
tool/config.sub already exists
checking build system type... arm-apple-darwin22.2.0
checking host system type... arm-apple-darwin22.2.0
checking target system type... arm-apple-darwin22.2.0
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... configure: error: in `/Users/myname/.rvm/src/ruby-2.7.1':
configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details
I tried...我试过...
rvm install 2.7.5
rvm install ruby-2.7.5
use rbenv使用 rbenv
install openssl安装 openssl
brew install openssl
rvm install 2.6.7 --with-openssl-dir=/usr/local/opt/openssl
all those throw same error message.所有这些都抛出相同的错误信息。 After trying 4., all ruby versions are removed but still can't install any ruby version.
尝试4.后,所有ruby版本都被删除,但仍然无法安装任何ruby版本。
Please help!!!请帮忙!!!
Edit I tried CFLAGS="-Wno-error=implicit-function-declaration" rvm install 2.7.5
编辑我试过
CFLAGS="-Wno-error=implicit-function-declaration" rvm install 2.7.5
and got this error并得到这个错误
Error running './configure --prefix=/Users/myname/.rvm/rubies/ruby-2.7.5 --with-opt-dir=/opt/homebrew/opt/libyaml:/opt/homebrew/opt/libksba:/opt/homebrew/opt/readline:/opt/homebrew/opt/zlib:/opt/homebrew/opt/openssl@1.1 --disable-install-doc --enable-shared',
please read /Users/myname/.rvm/log/1672116807_ruby-2.7.5/configure.log
There has been an error while running configure. Halting the installation.
EDIT-----编辑 - - -
export LDFLAGS="-L/opt/homebrew/opt/openssl@1.1/lib"
export CPPFLAGS="-I/opt/homebrew/opt/openssl@1.1/include"
export PKG_CONFIG_PATH="/opt/homebrew/opt/openssl@1.1/lib/pkgconfig"
export RUBY_CFLAGS=-DUSE_FFI_CLOSURE_ALLOC
export optflags="-Wno-error=implicit-function-declaration"
export LDFLAGS="-L/opt/homebrew/opt/openssl@1.1/lib"
export CPPFLAGS="-I/opt/homebrew/opt/openssl@1.1/include"
CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl@1.1)"
RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl@1.1)"
rvm install 2.7.5
this returns same error but I got this configure log这返回相同的错误,但我得到了这个配置日志
checking for ruby... /usr/bin/ruby
tool/config.guess already exists
tool/config.sub already exists
checking build system type... aarch64-apple-darwin22.2.0
checking host system type... aarch64-apple-darwin22.2.0
checking target system type... aarch64-apple-darwin22.2.0
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... configure: error: in `/Users/myname/.rvm/src/ruby-2.7.5':
configure: error: cannot run C compiled programs. // <---- new!
If you meant to cross compile, use `--host'.
See `config.log' for more details
Do you have xcode developer tools installed?你有安装 xcode 开发者工具吗? Run this "xcode-select --install"
运行这个“xcode-select --install”
xcode-select --install
Once you have developer tools installed you may need to refer to this comment:-安装开发人员工具后,您可能需要参考此评论:-
https://github.com/rbenv/ruby-build/discussions/1947#discussioncomment-2317356 https://github.com/rbenv/ruby-build/discussions/1947#discussioncomment-2317356
Add Command Line Tools:添加命令行工具:
open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
Here are the exact steps to follow assuming we have openssl installed假设我们安装了 openssl,这里是要遵循的确切步骤
export LDFLAGS="-L/opt/homebrew/opt/openssl@1.1/lib"
export CPPFLAGS="-I/opt/homebrew/opt/openssl@1.1/include"
export PKG_CONFIG_PATH="/opt/homebrew/opt/openssl@1.1/lib/pkgconfig"
export RUBY_CFLAGS=-DUSE_FFI_CLOSURE_ALLOC
export optflags="-Wno-error=implicit-function-declaration"
export LDFLAGS="-L/opt/homebrew/opt/openssl@1.1/lib"
export CPPFLAGS="-I/opt/homebrew/opt/openssl@1.1/include"
CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl@1.1)"
RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl@1.1)"
rvm install 2.7.5
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.