Rich
Rich

Reputation: 1051

Ruby won't install new version

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:

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] % 

Upvotes: 1

Views: 2807

Answers (1)

gsparks-sm
gsparks-sm

Reputation: 76

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 [email protected]
  1. Add the following lines to your .zshrc for the time being
export PATH="`brew --prefix [email protected]`/bin:$PATH"
export LDFLAGS="-L`brew --prefix [email protected]`/lib"
export CPPFLAGS="-I`brew --prefix [email protected]`/include"
export PKG_CONFIG_PATH="`brew --prefix [email protected]`/lib/pkgconfig"
export RUBY_CONFIGURE_OPTS="--with-openssl-dir=`brew --prefix [email protected]`"
  1. Close and reopen your terminal

  2. Run rbenv again, with CONFIGURE_OPTS enabled

CONFIGURE_OPTS=--with-openssl-dir=`brew --prefix [email protected]` rbenv install 2.7.6

Upvotes: 5

Related Questions