Home > database >  rbenv and Apple m1. Failed installing ruby 3.2, 2.7 and 2.6
rbenv and Apple m1. Failed installing ruby 3.2, 2.7 and 2.6

Time:01-29

I can't install any ruby version with rbenv. I tried 2.6.10 2.7.7 or 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. I don't know what to do. Should rbenv even suppose to work with m1 computers?

I have MacOS 13.1

CodePudding user response:

Setting the environment variable below solves the problem:

export RUBY_CONFIGURE_OPTS="--with-zlib-dir=$(brew --prefix zlib) --with-openssl-dir=$(brew --prefix [email protected]) --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.

Note: The configuration --with-openssl-dir=$(brew --prefix [email protected]) is needed only for versions 2.6.* and 2.7.*. You can (and should) remove it if you are trying to install ruby 3.*.*.

For 2.6 and 2.7 sometimes this environment variable also needed:

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

If all of the above didn't work, you can install ruby with Homebrew. If you want to manage the Homebrew installed version from rbenv read this answer.

  • Related