0

I'm trying to install Ruby 2.7.6 but when I run % rbenv version

I get:

rbenv: version 2.7.6' is not installed (set by /Users/[USER]/Documents/[FOLDER]/.ruby-version)

I have file .ruby-version containing: 2.7.6

When running: %. rbenv install It errors:

BUILD FAILED (macOS 12.5 using ruby-build 20220726)

NOTE:

  • current Ruby installed is 2.6.10 installed
  • running macOS v12.5 on MBP

TERMINAL trace

> (base) uxdw@MacBook-Pro [FOLDER] % rbenv install      
Downloading openssl-1.1.1q.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/d7939ce614029cdff0b6c20f0e2e5703158a489a72b2507b8bd51bf8c8fd10ca
Installing openssl-1.1.1q...
patching file test/v3ext.c
Installed openssl-1.1.1q to /Users/[USER]/.rbenv/versions/2.7.6

Downloading ruby-2.7.6.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.7/ruby-2.7.6.tar.bz2
Installing ruby-2.7.6...
ruby-build: using readline from homebrew

BUILD FAILED (macOS 12.5 using ruby-build 20220726)

Inspect or clean up the working tree at /var/folders/sz/svbmflb15kd5dy8g9kctn9t40000gn/T/ruby-build.20220805134427.72844.lmy9oj
Results logged to /var/folders/sz/svbmflb15kd5dy8g9kctn9t40000gn/T/ruby-build.20220805134427.72844.log

Last 10 log lines:
compiling date_parse.c
linking shared-object strscan.bundle
compiling date_strftime.c
compiling date_strptime.c
linking shared-object io/console.bundle
installing default date_core libraries
linking shared-object objspace.bundle
linking shared-object nkf.bundle
linking shared-object date_core.bundle
make: *** [build-ext] Error 2
(base) uxdw@MacBook-Pro [FOLDER] % 
tadman
  • 208,517
  • 23
  • 234
  • 262
Rich
  • 970
  • 2
  • 16
  • 42

1 Answers1

4

rbenv is installing openssl-1.1.1q as a prereq and it will crash out due to a missing include statement, at least one that exists in the ARM64 version. This is the case for M1 and M2 MBPs, so I'm guessing based on your description above.

  1. Install openssl (I used brew, ymmv)
brew install openssl@1.1
  1. Add the following lines to your .zshrc for the time being
export PATH="`brew --prefix openssl@1.1`/bin:$PATH"
export LDFLAGS="-L`brew --prefix openssl@1.1`/lib"
export CPPFLAGS="-I`brew --prefix openssl@1.1`/include"
export PKG_CONFIG_PATH="`brew --prefix openssl@1.1`/lib/pkgconfig"
export RUBY_CONFIGURE_OPTS="--with-openssl-dir=`brew --prefix openssl@1.1`"
  1. Close and reopen your terminal

  2. Run rbenv again, with CONFIGURE_OPTS enabled

CONFIGURE_OPTS=--with-openssl-dir=`brew --prefix openssl@1.1` rbenv install 2.7.6
Aure77
  • 3,034
  • 7
  • 33
  • 53
gsparks-sm
  • 66
  • 4
  • 1
    This is an ARM specific solution intended for M-series (2020+) MacBooks. Hopefully, this solution will no longer be relevant, as the openssl team works toward a solution targeting a patch version of 1.1.1 – gsparks-sm Aug 05 '22 at 14:12
  • 1
    thanks, I've gone through your steps. Openssl installs fine and added those lines to .zshrc but it's still failing on the install: ----- % sudo CONFIGURE_OPTS=--with-openssl-dir=`brew --prefix openssl@1.1` rbenv install 2.7.6 Downloading openssl-1.1.1q.tar.gz... -> https://dqw8nmjcqpjn7.cloudfront.net/d7939ce614029cdff0b6c20f0e2e5703158a489a72b2507b8bd51bf8c8fd10ca Installing openssl-1.1.1q... patching file test/v3ext.c BUILD FAILED (macOS 12.5 using ruby-build 20220726) – Rich Aug 05 '22 at 15:46
  • When I run just `brew --prefix openssl@1.1`, I can confirm it is already installed. Does your output look similar? `~ % brew --prefix openssl@1.1 #=> /opt/homebrew/opt/openssl@1.1` – gsparks-sm Aug 09 '22 at 13:28
  • Also, you shouldn't need `sudo` to install with `rbenv`. It should install it in local directories out of your `$HOME`. I wonder if the `sudo` call is interfering – gsparks-sm Aug 09 '22 at 13:30