Ruby:BUILD FAILED(macOS 11.2 using ruby-build 20210119)Mac大苏尔

rsaldnfx  于 2023-04-05  发布在  Ruby
关注(0)|答案(5)|浏览(561)

我看了这个Ruby installation (2.2.2) fails in macOS Big Sur
我的macOS是Big Sur,我的版本是11.2,这是我能找到的最接近我的操作系统的问题,我遵循了我所能尝试的

CFLAGS="-Wno-error=implicit-function-declaration" rbenv install 2.5.3

并且还

RUBY_CFLAGS=-DUSE_FFI_CLOSURE_ALLOC rbenv install 2.5.3

这是我的终端的输出:

Downloading openssl-1.1.1i.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/e8be6a35fe41d10603c3cc635e93289ed00bf34b79671a3a4de64fcee00d5242
Installing openssl-1.1.1i...
Installed openssl-1.1.1i to /Users/richard/.rbenv/versions/2.5.3

Downloading ruby-2.5.3.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.5/ruby-2.5.3.tar.bz2
Installing ruby-2.5.3...

WARNING: ruby-2.5.3 is nearing its end of life.
It only receives critical security updates, no bug fixes.

ruby-build: using readline from homebrew
/opt/homebrew/bin/ruby-build: line 1121: 31528 Killed: 9               "$RUBY_BIN" -e '
    manager = ARGV[0]
    packages = {
      "apt-get" => Hash.new {|h,k| "lib#{k}-dev" }.update(
        "openssl" => "libssl-dev",
        "zlib" => "zlib1g-dev"
      ),
      "yum" => Hash.new {|h,k| "#{k}-devel" }.update(
        "yaml" => "libyaml-devel"
      )
    }

    failed = %w[openssl readline zlib yaml].reject do |lib|
      begin
        require lib
      rescue LoadError
        $stderr.puts "The Ruby #{lib} extension was not compiled."
      end
    end

    if failed.size > 0
      $stderr.puts "ERROR: Ruby install aborted due to missing extensions"
      $stderr.print "Try running `%s install -y %s` to fetch missing dependencies.\n\n" % [
        manager,
        failed.map { |lib| packages.fetch(manager)[lib] }.join(" ")
      ] unless manager.empty?
      $stderr.puts "Configure options used:"
      require "rbconfig"; require "shellwords"
      RbConfig::CONFIG.fetch("configure_args").shellsplit.each { |arg| $stderr.puts "  #{arg}" }
      exit 1
    end
  ' "$(basename "$(type -p yum apt-get | head -1)")" 1>&4 2>&1

BUILD FAILED (macOS 11.2 using ruby-build 20210119)

Inspect or clean up the working tree at /var/folders/rn/c7nmr3x12gg5r8qwsr4ty8hh0000gn/T/ruby-build.20210209143521.94730.xfFT9O
Results logged to /var/folders/rn/c7nmr3x12gg5r8qwsr4ty8hh0000gn/T/ruby-build.20210209143521.94730.log

Last 10 log lines:
installing bundled gems:            /Users/richard/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0 (build_info, cache, doc, extensions, gems, specifications)
                                    power_assert 1.1.1
                                    net-telnet 0.1.1
                                    did_you_mean 1.2.0
                                    xmlrpc 0.3.0
                                    rake 12.3.0
                                    minitest 5.10.3
                                    test-unit 3.2.7
installing rdoc:                    /Users/richard/.rbenv/versions/2.5.3/share/ri/2.5.0/system
installing capi-docs:               /Users/richard/.rbenv/versions/2.5.3/share/doc/ruby

我在上面提到的两个命令中都得到了这个错误,并且都给予了相同的输出。Ruby的版本似乎也不重要,我也尝试了3.0.0,得到了相同的结果。
另外,这是我尝试使用rbenv install安装ruby时的原始输出

Downloading openssl-1.1.1i.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/e8be6a35fe41d10603c3cc635e93289ed00bf34b79671a3a4de64fcee00d5242
Installing openssl-1.1.1i...
Installed openssl-1.1.1i to /Users/richard/.rbenv/versions/2.5.3
Downloading ruby-2.5.3.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.5/ruby-2.5.3.tar.bz2
Installing ruby-2.5.3...
WARNING: ruby-2.5.3 is nearing its end of life.
It only receives critical security updates, no bug fixes.
ruby-build: using readline from homebrew
BUILD FAILED (macOS 11.2 using ruby-build 20210119)
Inspect or clean up the working tree at /var/folders/rn/c7nmr3x12gg5r8qwsr4ty8hh0000gn/T/ruby-build.20210209143107.60561.YqaRpk
Results logged to /var/folders/rn/c7nmr3x12gg5r8qwsr4ty8hh0000gn/T/ruby-build.20210209143107.60561.log
Last 10 log lines:
compiling ../.././ext/psych/yaml/reader.c
compiling ../.././ext/psych/yaml/emitter.c
compiling ../.././ext/psych/yaml/parser.c
linking shared-object json/ext/generator.bundle
5 warnings generated.
linking shared-object date_core.bundle
linking shared-object zlib.bundle
1 warning generated.
linking shared-object psych.bundle
make: *** [build-ext] Error 2

xcode-select版本是2384。
Homebrew版本是3.0.0,brew doctor说我准备好了。
我的.zshrc文件也包含这行eval "$(rbenv init -)"
在这一点上,我不知道还能去哪里,🤷如果有任何细节,你想在日志文件中看到,让我知道从哪里,日志文件太大,无法在这里分享。为什么会发生这种情况,我如何解决这个问题?🤦‍♂️

6qftjkof

6qftjkof1#

这不是一个官方的解决方案。我相信rbenv开发人员正在研究一个实际的解决方案,但这个解决方案应该可以帮助其他人在新的Mac M1芯片上设置他们的Ruby环境。

  • 确保您的终端使用Rosetta。您可以使用Google找到如何做到这一点。
  • 按照以下说明卸载当前的rbenv删除rbenv。如果/Users/<your user name>/.rbenv/versions/中有任何ruby的下载版本(减去系统默认值),请确保您也删除了所有下载版本。
  • 使用以下命令卸载Homebrew的ARM版本:/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall.sh)"
  • 安装x86_64版本的Homebrew:arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
  • 如果你运行brew install rbenv,应该会产生一个输出“Error:无法以英特尔默认前缀(/usr/local)在ARM处理器上的Homebrew中安装!"。这是预期的。
  • 您想告诉brew安装旧的体系结构x86_64 arch -x86_64 brew install rbenv
  • 最后,使用arch -x86_64 rbenv install x.x.x(x =某个数字,即2.7.2)安装您想要的版本。

在安装其他版本的Ruby时,你只需要记住告诉brew arch -x86_64
一旦真正的修复完成,你就可以切换回新的架构,而不必使用arch参数,你也不必总是使用brew,只需rbenv。

baubqpgj

baubqpgj2#

在安装rbenv时,我在 MacOS Monterey 12.2(M1 Pro芯片) 上遇到了同样的问题。这个解决方案对我很有效-
而不是运行这个-rbenv install 2.5.3
运行此-RUBY_CFLAGS="-Wno-error=implicit-function-declaration" rbenv install 2.5.3

qxsslcnc

qxsslcnc3#

在安装readline openssl之后,我能够安装Ruby 2.7.2

brew install readline openssl
rbenv install 2.7.2
5fjcxozz

5fjcxozz4#

我正在使用rvm,我阅读并尝试了这里讨论的解决方案https://github.com/rvm/rvm/issues/5033
但是,对我有效的是rvm install "ruby-2.6.3" --with-out-ext=fiddle
如果您使用的是rbenv,您可以按照here的讨论进行操作

pvcm50d1

pvcm50d15#

这对我很有效

CFLAGS="-Wno-error=implicit-function-declaration" rbenv install 2.5.3

相关问题