通过 RVM 安装 Ruby 时运行配置时出错"C 编译器无法创建可执行文件"



无论出于何种原因,我刚刚内爆了我的RVM(工作正常)并尝试再次安装它。我遇到一个错误,在 RVM 测试编译器时阻止安装。我将不胜感激任何帮助调试这个。

运行以下操作后出现问题:

$ rvm install 2.6.2

任何其他版本的 Ruby。

我得到以下输出

Error running './configure --prefix=/Users/andres/.rvm/rubies/ruby-
2.6.2  --with-opt-dir=/usr/local/opt/libyaml:/usr/local/opt/readline:/usr/local/opt/libksba:/usr/local/opt/openssl@1.1 --disable-install-doc --enable-shared',
please read /Users/andres/.rvm/log/1554329766_ruby-2.6.2/configure.log
There has been an error while running configure. Halting the installation.

配置.log显示

[2019-04-04 09:07:04] ./configure
current path: /Users/andres/.rvm/src/ruby-2.6.0
PATH=/usr/local/opt/coreutils/bin:/usr/local/opt/pkg-config/bin:/usr/local/opt/libtool/bin:/usr/local/opt/automake/bin:/usr/local/opt/autoconf/bin:/usr/local/opt/node@8/bin:/usr/local/opt/node@8/bin:/opt/local/bin:/opt/local/sbin:/Users/andres/bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/opt/node@8/bin:/opt/local/bin:/opt/local/sbin:/Users/andres/bin:/Users/andres/.rvm/bin
command(5): ./configure --prefix=/Users/andres/.rvm/rubies/ruby-2.6.0 --with-opt-dir=/usr/local/opt/libyaml:/usr/local/opt/readline:/usr/local/opt/libksba:/usr/local/opt/openssl@1.1 --disable-install-doc --enable-shared
checking for ruby... /usr/bin/ruby
tool/config.guess already exists
tool/config.sub already exists
checking build system type... x86_64-apple-darwin18.5.0
checking host system type... x86_64-apple-darwin18.5.0
checking target system type... x86_64-apple-darwin18.5.0
checking whether the C compiler works... no
configure: error: in `/Users/andres/.rvm/src/ruby-2.6.0':
configure: error: C compiler cannot create executables
See `config.log' for more details

相关配置.log行

## ----------- ##
## Core tests. ##
## ----------- ##
configure:2996: checking for ruby
configure:3014: found /usr/bin/ruby
configure:3027: result: /usr/bin/ruby
configure:3105: checking build system type
configure:3119: result: x86_64-apple-darwin18.5.0
configure:3207: checking host system type
configure:3220: result: x86_64-apple-darwin18.5.0
configure:3240: checking target system type
configure:3253: result: x86_64-apple-darwin18.5.0
configure:3905: checking for C compiler version
configure:3914: gcc --version >&5
Apple LLVM version 9.1.0 (clang-902.0.39.1)
Target: x86_64-apple-darwin18.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/c++/4.2.1
configure:3925: $? = 0
configure:3914: gcc -v >&5
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/c++/4.2.1
Apple LLVM version 9.1.0 (clang-902.0.39.1)
Target: x86_64-apple-darwin18.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
configure:3925: $? = 0
configure:3914: gcc -V >&5
clang: error: argument to '-V' is missing (expected 1 value)
clang: error: no input files
configure:3925: $? = 1
configure:3914: gcc -qversion >&5
clang: error: unknown argument: '-qversion'
clang: error: no input files
configure:3925: $? = 1
configure:3945: checking whether the C compiler works
configure:3967: gcc    conftest.c  >&5
ld: malformed file
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/lib/libSystem.tbd:4:18: error: unknown enumerated scalar
platform:        zippered
^~~~~~~~
file '/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/lib/libSystem.tbd'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
configure:3971: $? = 1
configure:4009: result: no
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME ""
| #define PACKAGE_TARNAME ""
| #define PACKAGE_VERSION ""
| #define PACKAGE_STRING ""
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| /* end confdefs.h.  */
| 
| int
| main ()
| {
| 
|   ;
|   return 0;
| }
configure:4014: error: in `/Users/andres/.rvm/src/ruby-2.6.0':
configure:4016: error: C compiler cannot create executables
See `config.log' for more details

环境:

  • MacOS 莫哈韦
  • Xcode 完全安装了 CL 工具(版本 9.3 -9E145-)
  • RVM 1.29.7 (最新)
  • gcc -v输出:

    配置:--prefix=/Applications/Xcode.app/Content/Developer/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/c++/4.2.1 Apple LLVM 版本 9.1.0 (clang-902.0.39.1) 目标:x86_64-苹果-达尔文18.5.0 螺纹型号:磅 InstalledDir:/applications/Xcode.app/Content/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

  • clang --version输出:

    Apple LLVM 版本 9.1.0 (clang-902.0.39.1) 目标:x86_64-苹果-达尔文18.5.0 螺纹型号:磅 InstalledDir:/applications/Xcode.app/Content/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

    • xcode-select -p输出:/Applications/Xcode.app/Contents/Developer

我已经尝试了 (1) 一次又一次地重新安装 RVM。(2) 运行rvm get stable --autolibs=enable --auto-dotfiles以修复 bash 等的任何问题 (3) 确保 Xcode 已更新。(4) 运行 rvm install 2.6.2 --with-gcc=clang(如一些 SO 答案中所建议的那样)。

所有这些都没有成功。感谢您的帮助。

--- 其他信息 ---

gem env输出

RubyGems Environment:
- RUBYGEMS VERSION: 2.5.2.3
- RUBY VERSION: 2.3.7 (2018-03-28 patchlevel 456) [universal.x86_64-darwin18]
- INSTALLATION DIRECTORY: /Library/Ruby/Gems/2.3.0
- USER INSTALLATION DIRECTORY: /Users/andres/.gem/ruby/2.3.0
- RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby
- EXECUTABLE DIRECTORY: /usr/local/bin
- SPEC CACHE DIRECTORY: /Users/andres/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Library/Ruby/Site
- RUBYGEMS PLATFORMS:
- ruby
- universal-darwin-18
- GEM PATHS:
- /Library/Ruby/Gems/2.3.0
- /Users/andres/.gem/ruby/2.3.0
- /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/gems/2.3.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- "gem" => "--no-document"
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /usr/local/opt/node@8/bin
- /usr/local/opt/node@8/bin
- /opt/local/bin
- /opt/local/sbin
- /Users/andres/bin
- /usr/local/bin
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /usr/local/opt/node@8/bin
- /opt/local/bin
- /opt/local/sbin
- /Users/andres/bin
- /Users/andres/.rvm/bin
- /Users/andres/.rvm/bin
- /Users/andres/.rvm/bin

我认为你的xcode版本已经过时了。升级到 10.2 应该可以修复它。

最新更新