[英]Mac OS - m1: Can't install ruby 2.7.5 because of an error from configure
我需要為我的本機反應應用程序安裝 ruby 2.7.5,但我無法通過 rvm 安裝 2.7.5。 我嘗試了很多東西來安裝任何 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.
這是配置日志
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
我試過...
rvm install 2.7.5
rvm install ruby-2.7.5
使用 rbenv
安裝 openssl
brew install openssl
rvm install 2.6.7 --with-openssl-dir=/usr/local/opt/openssl
所有這些都拋出相同的錯誤信息。 嘗試4.后,所有ruby版本都被刪除,但仍然無法安裝任何ruby版本。
請幫忙!!!
編輯我試過CFLAGS="-Wno-error=implicit-function-declaration" rvm install 2.7.5
並得到這個錯誤
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.
編輯 - - -
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
這返回相同的錯誤,但我得到了這個配置日志
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
你有安裝 xcode 開發者工具嗎? 運行這個“xcode-select --install”
xcode-select --install
安裝開發人員工具后,您可能需要參考此評論:-
https://github.com/rbenv/ruby-build/discussions/1947#discussioncomment-2317356
添加命令行工具:
open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
假設我們安裝了 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.