简体   繁体   English

rbenv 和 Apple m1。 安装 ruby 3.2、2.7 和 2.6 失败

[英]rbenv and Apple m1. Failed installing ruby 3.2, 2.7 and 2.6

I can't install any ruby version with rbenv.我无法使用 rbenv 安装任何 ruby 版本。 I tried 2.6.10 2.7.7 or 3.2.0.我试过 2.6.10 2.7.7 或 3.2.0。

This is the error I got when executing:这是我在执行时得到的错误:

❯ rbenv install 3.2.0
To follow progress, use 'tail -f /var/folders/4v/kyv3nw1s7lq8s7lz7r6djvsr0000gn/T/ruby-build.20230125170342.85553.log' or pass --verbose
Downloading openssl-3.0.7.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/83049d042a260e696f62406ac5c08bf706fd84383f945cf21bd61e9ed95c396e
Installing openssl-3.0.7...
Installed openssl-3.0.7 to /Users/idanahal/.rbenv/versions/3.2.0

Downloading ruby-3.2.0.tar.gz...
-> https://cache.ruby-lang.org/pub/ruby/3.2/ruby-3.2.0.tar.gz
Installing ruby-3.2.0...
ruby-build: using readline from homebrew
ruby-build: using gmp from homebrew

BUILD FAILED (macOS 13.1 using ruby-build 20221225)

Inspect or clean up the working tree at /var/folders/4v/kyv3nw1s7lq8s7lz7r6djvsr0000gn/T/ruby-build.20230125170342.85553.VSOgmw
Results logged to /var/folders/4v/kyv3nw1s7lq8s7lz7r6djvsr0000gn/T/ruby-build.20230125170342.85553.log

Last 10 log lines:
compiling ossl_x509ext.c
compiling ossl_x509name.c
compiling ossl_x509req.c
compiling ossl_x509revoked.c
compiling ossl_x509store.c
installing default openssl libraries
linking shared-object date_core.bundle
linking shared-object openssl.bundle
linking shared-object ripper.bundle
make: *** [build-ext] Error 2

When installing with Homebrew it's working.使用 Homebrew 安装时可以正常工作。 I don't know what to do.我不知道该怎么办。 Should rbenv even suppose to work with m1 computers? rbenv 是否应该与 m1 计算机一起工作?

I have MacOS 13.1我有 MacOS 13.1

Setting the environment variable below solves the problem:设置下面的环境变量解决了这个问题:

export RUBY_CONFIGURE_OPTS="--with-zlib-dir=$(brew --prefix zlib) --with-openssl-dir=$(brew --prefix openssl@1.1) --with-readline-dir=$(brew --prefix readline) --with-libyaml-dir=$(brew --prefix libyaml) --with-gdbm-dir=$(brew --prefix gdbm)"

before running rbenv install for all versions.在为所有版本运行rbenv install之前。

Note: The configuration --with-openssl-dir=$(brew --prefix openssl@1.1) is needed only for versions 2.6.* and 2.7.* .注意:只有版本2.6.*2.7.*才需要配置--with-openssl-dir=$(brew --prefix openssl@1.1) You can (and should) remove it if you are trying to install ruby 3.*.* .如果您尝试安装 ruby 3.*.* ,您可以(并且应该)删除它。

For 2.6 and 2.7 sometimes this environment variable also needed:对于 2.6 和 2.7,有时还需要这个环境变量:

export RUBY_CFLAGS="-Wno-error=implicit-function-declaration"

If all of the above didn't work, you can install ruby with Homebrew.如果以上所有方法都不起作用,您可以使用 Homebrew 安装 ruby。 If you want to manage the Homebrew installed version from rbenv read this answer .如果您想从 rbenv 管理 Homebrew 安装版本,请阅读此答案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM