使用 rvm 安装 Ruby 时出错:“__rvm_make -j8”

dav*_*j95 8 ruby macos openssl compiler-errors rvm

我试图使用安装最新的稳定 Ruby 版本(3.1.x3.2.xrvm。但是,rvm install编译 Ruby 时,任何这些版本的命令都会失败。例如,当尝试运行时

rvm install 3.1.4
Run Code Online (Sandbox Code Playgroud)

我得到以下输出:

Searching for binary rubies, this might take some time.
No binary rubies available for: osx/13.5/arm64/ruby-3.1.4.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for osx.
Updating certificates bundle '/opt/homebrew/etc/openssl@1.1/cert.pem'
Requirements installation successful.
Installing Ruby from source to: /Users/davidlj95/.rvm/rubies/ruby-3.1.4, this may take a while depending on your cpu(s)...
ruby-3.1.4 - #downloading ruby-3.1.4, this may take a while depending on your connection...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 19.9M  100 19.9M    0     0  12.8M      0  0:00:01  0:00:01 --:--:-- 12.8M
No checksum for downloaded archive, recording checksum in user configuration.
/Users/davidlj95/.rvm/tmp/rvm_src_74481
ruby-3.1.4 - #extracting ruby-3.1.4 to /Users/davidlj95/.rvm/src/ruby-3.1.4 - please wait
ruby-3.1.4 - #configuring - please wait
ruby-3.1.4 - #post-configuration - please wait
ruby-3.1.4 - #compiling - please wait
Error running '__rvm_make -j8',
please read /Users/davidlj95/.rvm/log/1692282742_ruby-3.1.4/make.log

There has been an error while running make. Halting the installation.
Run Code Online (Sandbox Code Playgroud)

在文件中查找错误less -p error /Users/davidlj95/.rvm/log/1692282742_ruby-3.1.4/make.log

失败之前出现的最后一个错误似乎与 OpenSSL 有关:

ossl_ts.c:829:5: error: incomplete definition of type 'struct TS_verify_ctx'
    TS_VERIFY_CTX_set_certs(ctx, x509inter);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ...
make[1]: *** [ext/openssl/all] Error 2
make: *** [build-ext] Error 2
+__rvm_make:0> return 2
1 warning and 1 error generated.
Run Code Online (Sandbox Code Playgroud)

我使用的是 M1 / ARM 芯片组的 MacBook Pro。使用 macOS Ventura 13.5。

我试过了:

  • 安装出现在的最新版本rvm list known3.0.0。它也失败了。
  • 转到已提取并运行 Ruby 源代码的路径make -j8。由于同样的原因失败。
  • brew install openssl@1.1看到后您可能需要旧版本的 OpenSSL 来构建 Ruby。它已经安装好了。也没有运气。
  • 确保 OpenSSL 出现的位置Makefile存在
  • 安装最新版本的 OpenSSL:brew install openssl@3. 也没有运气。

dav*_*j95 23

正如Ruby 构建指南所建议的那样,导出预编译步骤的配置参数环境变量,指示Homebrew安装的库的安装位置。您可以通过运行以下命令来执行此操作:

export CONFIGURE_ARGS=""
for ext in openssl readline libyaml zlib; do 
  CONFIGURE_ARGS="${CONFIGURE_ARGS} --with-$ext-dir=$(brew --prefix $ext)" 
done
Run Code Online (Sandbox Code Playgroud)

然后,运行rvm install命令。编译成功并安装了 Ruby 版本。曾工作过多个 Ruby 版本。