3

I am trying to install Ruby on my mac and that too the latest version but having trouble.

The pre-installed ruby on mac is of verion 2.0 however, I need to upgrade the same to latest.

I tried installing ruby with Homebrew like brew install ruby but whenever i check the version, it shows me the earlier version only. Refer Terminal screenshot:

enter image description here

Am trying to learn ruby but this thing got me stuck for long.

Have also tried another package manager rbenv and did rbenv install 2.5.1 but that failed with the following error I have no idea about

The Ruby zlib extension was not compiled.
ERROR: Ruby install aborted due to missing extensions
Configure options used:
  --prefix=/Users/vshukla/.rbenv/versions/2.5.1
  --with-openssl-dir=/usr/local/opt/openssl
  CC=clang
  CFLAGS= -O3 -Wno-error=shorten-64-to-32 
  LDFLAGS=-L/Users/vshukla/.rbenv/versions/2.5.1/lib 
  CPPFLAGS=-I/Users/vshukla/.rbenv/versions/2.5.1/include 

Please guide.

roger_that
  • 9,493
  • 18
  • 66
  • 102
  • 2
    Ok, this comment is opinion based :) I suggest you to stick with Homebrew and rvm. Try follow this guide: https://www.moncefbelyamani.com/how-to-install-xcode-homebrew-git-rvm-ruby-on-mac/ – iGian Jul 31 '18 at 05:09
  • Possible duplicate of [rbenv installed ruby 2.1.2 cannot load such file -- zlib on MAC OSX 10.9.2](https://stackoverflow.com/questions/23781657/rbenv-installed-ruby-2-1-2-cannot-load-such-file-zlib-on-mac-osx-10-9-2) – Aaron Breckenridge Jul 31 '18 at 14:28

2 Answers2

3

Homebrew has correctly installed the last version of ruby in /usr/local/bin. You can check it with:

/usr/local/bin/ruby --version

The macOS version of ruby is installed in /usr/bin. You can check it with:

/usr/bin/ruby --version

If you want to always run the Homebrew versions of installed tools, you have to put /use/local/bin before /usr/bin in your PATH environment variable. You can do this by adding the following line in your ~/.bash_profile:

export PATH="/usr/local/bin:$PATH"

P.S.: According to your macos ruby version, you don't have the last macOS version.

Ortomala Lokni
  • 56,620
  • 24
  • 188
  • 240
0

The compile error log contains:

The Ruby zlib extension was not compiled.

ERROR: Ruby install aborted due to missing extensions

Try installing "zlib" and then try again, by running:

brew install zlib
Aviram Fireberger
  • 3,910
  • 5
  • 50
  • 69