mac os ruby 安装失败 -> make -j 8

问题描述 投票:0回答:1

我尝试过

rbenv
rvm
asdf
,但都失败了
-> make -j 8

Apple M1
14.3 (Sonoma)
asdf install ruby latest 
ruby-build: using openssl@3 from homebrew
==> Downloading ruby-3.3.0.tar.gz...
-> curl -q -fL -o ruby-3.3.0.tar.gz https://cache.ruby-lang.org/pub/ruby/3.3/ruby-3.3.0.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 21.0M  100 21.0M    0     0  8732k      0  0:00:02  0:00:02 --:--:-- 8734k
==> Installing ruby-3.3.0...
ruby-build: using libyaml from homebrew
ruby-build: using gmp from homebrew
-> ./configure "--prefix=$HOME/.asdf/installs/ruby/3.3.0" --with-openssl-dir=/usr/local/opt/openssl@3 --enable-shared --with-libyaml-dir=/usr/local/opt/libyaml --with-gmp-dir=/usr/local/opt/gmp --with-ext=openssl,psych,+
-> make -j 8
*** Following extensions are not compiled:
openssl:
        Could not be configured. It will not be installed.
        /private/var/folders/hz/hfxt6dnj14v6_6qt7t23ppm80000gn/T/ruby-build.20240226205446.26544.yrtoY7/ruby-3.3.0/ext/openssl/extconf.rb:122: OpenSSL library could not be found. You might want to use --with-openssl-dir=<dir> option to specify the prefix where OpenSSL is installed.
        Check /var/folders/hz/hfxt6dnj14v6_6qt7t23ppm80000gn/T/ruby-build.20240226205446.26544.yrtoY7/ruby-3.3.0/ext/openssl/mkmf.log for more details.
psych:
        Could not be configured. It will not be installed.
        Check /var/folders/hz/hfxt6dnj14v6_6qt7t23ppm80000gn/T/ruby-build.20240226205446.26544.yrtoY7/ruby-3.3.0/ext/psych/mkmf.log for more details.

BUILD FAILED (macOS 14.3 on arm64 using ruby-build 20240221)

You can inspect the build directory at /var/folders/hz/hfxt6dnj14v6_6qt7t23ppm80000gn/T/ruby-build.20240226205446.26544.yrtoY7
See the full build log at /var/folders/hz/hfxt6dnj14v6_6qt7t23ppm80000gn/T/ruby-build.20240226205446.26544.log
brew --prefix openssl
/usr/local/opt/openssl@3
ls -la /usr/local/opt/openssl@3
lrwxr-xr-x@ 1 a  admin  25 Feb 26 20:54 /usr/local/opt/openssl@3 -> ../Cellar/openssl@3/3.2.1

日志

=== Checking for required stuff failed. ===
Makefile wasn't created. Fix the errors above.
/private/var/folders/hz/hfxt6dnj14v6_6qt7t23ppm80000gn/T/ruby-build.20240226205446.26544.yrtoY7/ruby-3.3.0/ext/openssl/extconf.rb:122: OpenSSL library could not be found. You might want to use --with-openssl-dir=<dir> option to specify the prefix where OpenSSL is installed.
    /private/var/folders/hz/hfxt6dnj14v6_6qt7t23ppm80000gn/T/ruby-build.20240226205446.26544.yrtoY7/ruby-3.3.0/ext/openssl/extconf.rb:122:in `<top (required)>'
    ./ext/extmk.rb:219:in `load'
    ./ext/extmk.rb:219:in `block in extmake'
    /private/var/folders/hz/hfxt6dnj14v6_6qt7t23ppm80000gn/T/ruby-build.20240226205446.26544.yrtoY7/ruby-3.3.0/lib/mkmf.rb:314:in `open'
    ./ext/extmk.rb:215:in `extmake'
    ./ext/extmk.rb:634:in `block in <main>'
    ./ext/extmk.rb:630:in `each'
    ./ext/extmk.rb:630:in `<main>'
ld: warning: ignoring file '/usr/local/Cellar/libyaml/0.2.5/lib/libyaml-0.2.dylib': found architecture 'x86_64', required architecture 'arm64'
ld: Undefined symbols:
  _yaml_get_version, referenced from:
      _t in conftest-a05b11.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)
checked program was:
/* begin */
 1: #include "ruby.h"
 2:
 3: /*top*/
 4: extern int t(void);
 5: int main(int argc, char **argv)
 6: {
 7:   if (argc > 1000000) {
 8:     int (* volatile tp)(void)=(int (*)(void))&t;
 9:     printf("%d", (*tp)());
10:   }
11:
12:   return !!argv[argc];
13: }
14: extern void yaml_get_version();
15: int t(void) { yaml_get_version(); return 0; }
/* end */
ruby macos homebrew
1个回答
0
投票

我的酿造设置为:

which brew
/usr/local/bin/brew

这导致它使用 x86 进行安装。

确保其设置为:

which brew
/opt/homebrew/bin/brew

为我的 M1 Mac 正确安装arm64。

这解决了 openssl、libyaml、psych 等的问题,成功安装了 ruby。

© www.soinside.com 2019 - 2024. All rights reserved.