Ruby-build: Ruby zlib extension was not compiled OS X 10.9.5

Created on 19 Nov 2015  路  24Comments  路  Source: rbenv/ruby-build

trying to get ruby 2.2.3 running on this computer. curiously, i was able to do this just fine on a different computer earlier today (probably running 10.8 or 10.9). also tried 2.2.2, same result.

I'm guessing there's just something trivial I need to do, but I'm a little dicey on this kind of stuff.

Here's the log when I run rbenv install 2.2.3

Downloading ruby-2.2.3.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/df795f2f99860745a416092a4004b016ccf77e8b82dec956b120f18bdc71edce
Installing ruby-2.2.3...

BUILD FAILED (OS X 10.9.5 using ruby-build 20151028)

Inspect or clean up the working tree at /var/folders/zp/snp4qhvj401d3jnp2ltql9c40000gn/T/ruby-build.20151118232539.75260
Results logged to /var/folders/zp/snp4qhvj401d3jnp2ltql9c40000gn/T/ruby-build.20151118232539.75260.log

Last 10 log lines:
installing capi-docs:         /Users/chasedelanguillette/.rbenv/versions/2.2.3/share/doc/ruby
The Ruby zlib extension was not compiled.
ERROR: Ruby install aborted due to missing extensions
Configure options used:
  --prefix=/Users/chasedelanguillette/.rbenv/versions/2.2.3
  --with-openssl-dir=/usr/local/opt/openssl
  --with-readline-dir=/usr/local/opt/readline
  CFLAGS= -O3 -Wno-error=shorten-64-to-32 
  LDFLAGS=-L/Users/chasedelanguillette/.rbenv/versions/2.2.3/lib 
  CPPFLAGS=-I/Users/chasedelanguillette/.rbenv/versions/2.2.3/include 
unconfirmed x-platform

Most helpful comment

I had the same issue and the following worked.

# if all else fails, resort to Homebrew:
brew install zlib
LDFLAGS=-L/usr/local/opt/zlib/lib CPPFLAGS=-I/usr/local/opt/zlib/include rbenv install 2.3.0

All 24 comments

omg, totally listed this in the wrong github page. too many tabs open trying to fix this. sorry!

You totally listed this in the right GitHub repo :wink: The ruby-build project is responsible for rbenv install command.

That's a very interesting error. Rubies were known to compile without problems using OS X system libzlib. For you, it failed for some reason. Have you installed a custom zlib somehow?

that's a great question. i've done numerous things to the computer in question over the years so maybe. how would i know where to look?

I'm not sure how to look :(

You could always try to install zlib with Homebrew and use RUBY_CONFIGURE_OPTS=--with-zlib-dir="$(brew --prefix zlib)". Maybe that would work

Other things to try:

ls /usr/lib/libz*
# should produce:
# /usr/lib/libz.1.1.3.dylib
# /usr/lib/libz.1.2.5.dylib
# /usr/lib/libz.1.dylib
# /usr/lib/libz.dylib

# if all else fails, resort to Homebrew:
brew install zlib
LDFLAGS=-L/usr/local/opt/zlib/lib CPPFLAGS=-I/usr/local/opt/zlib/include rbenv install 2.2.4

I had the same issue and the following worked.

# if all else fails, resort to Homebrew:
brew install zlib
LDFLAGS=-L/usr/local/opt/zlib/lib CPPFLAGS=-I/usr/local/opt/zlib/include rbenv install 2.3.0

Thanks for sharing that it worked for you, @renatomoya. Could you also share your output of ls -l /usr/lib/libz*?

The reason I'm confused about this is that Ruby should compile well against system version of zlib on OS X. The Homebrew step shouldn't be necessary, but for some people it mysteriously is.

thanks for not giving up on this, i practically had :)

I tried punching in the things that were suggested here, but i still have the same zlib errors

Here's my output when i run ls -l /usr/lib/libz*

    lrwxr-xr-x  1 root  wheel      16 Oct  5  2013 /usr/lib/libz.1.1.3.dylib -> libz.1.2.5.dylib
    -rwxr-xr-x  1 root  wheel  169392 Oct  5  2013 /usr/lib/libz.1.2.5.dylib
    lrwxr-xr-x  1 root  wheel      16 Oct  5  2013 /usr/lib/libz.1.dylib -> libz.1.2.5.dylib
    lrwxr-xr-x  1 root  wheel      16 Oct  5  2013 /usr/lib/libz.dylib -> libz.1.2.5.dylib

quick question, when you said "You could always try to install zlib with Homebrew and use RUBY_CONFIGURE_OPTS=--with-zlib-dir="$(brew --prefix zlib)""...tell me more about that RUBY_CONFIGURE_OPTS part. do i just punch that line into terminal and hit enter? or am I supposed to tack that on the rbenv install 2.3.0 command?

You would literally do these commands in the terminal:

brew install zlib
RUBY_CONFIGURE_OPTS="--with-zlib-dir=$(brew --prefix zlib)" rbenv install 2.2.3

Everyone: When someone experiences a zlib failure on OS X without using Homebrew zlib next, could you please paste the full build log (stored in a file as indicated) as a gist and paste the link here? Thanks.

oh ok. i figured the RUBY_CONFIGURE_OPTS line and the rbenv line were separate and meant to be entered seperately. i pasted the entire line and it works! Thanks so much!

@mislav This is ls -l /usr/lib/libz* output:

lrwxr-xr-x  1 root  wheel      12 Jun 30  2015 /usr/lib/libz.1.1.3.dylib -> libz.1.dylib
lrwxr-xr-x  1 root  wheel      12 Jun 30  2015 /usr/lib/libz.1.2.5.dylib -> libz.1.dylib
-rwxr-xr-x  1 root  wheel  169312 Sep  9  2014 /usr/lib/libz.1.dylib
lrwxr-xr-x  1 root  wheel      12 Jun 30  2015 /usr/lib/libz.dylib -> libz.1.dylib

@renatomoya That looks alright; thanks for sharing. It's really weird that Ruby has trouble linking to zlib for only specific people.

Next time this happens to anyone, please share the full build log as a gist so that I can inspect any zlib-related output. Thanks!

Hi,

I just ran into this trying to install 2.3.0 on OS X El Capitan:

RUBY_CONFIGURE_OPTS=--with-readline-dir="$(brew --prefix readline)" rbenv install 2.3.0

Here's the full log without zlib installed via Homebrew.

$ ls -lha /usr/local/lib/libz*
-rw-rw-r--  1 root  wheel    89K Feb 13  2009 /usr/local/lib/libz.a
$ ls -lha /usr/lib/libz*
lrwxr-xr-x  1 root  wheel    12B Sep 30 15:38 /usr/lib/libz.1.1.3.dylib -> libz.1.dylib
lrwxr-xr-x  1 root  wheel    12B Sep 30 15:38 /usr/lib/libz.1.2.5.dylib -> libz.1.dylib
-rwxr-xr-x  1 root  wheel   173K Dec  3 01:36 /usr/lib/libz.1.dylib
lrwxr-xr-x  1 root  wheel    12B Sep 30 15:38 /usr/lib/libz.dylib -> libz.1.dylib

EDIT

Here's the mkmf.log from the ext/zlib directory. No idea what's going on here. If I run ruby extconf.rb && make manually for this directory it compiles fine:

ruby ./extconf.rb  && make
checking for deflateReset() in -lz... yes
checking for zlib.h... yes
checking for crc32_combine() in zlib.h... yes
checking for adler32_combine() in zlib.h... yes
checking for z_crc_t in zlib.h... no
creating Makefile
linking shared-object zlib.bundle

@ledbettj Thanks for sharing! Does the error go away if you remove /usr/local/lib/libz.a? What installed it in the first place?

@mislav Yup, I just tried that (unsure what dropped it there -- it wasn't homebrew) and yes, the install completed fine with no errors. Unsure if this is related to the original issue here though. Thanks for the help!

@ledbettj Thanks for checking! It's quite possible that other people reporting this issue might have had something in their /usr/local/lib/libz* too; probably an artifact of unrelated installs in the past.

@mislav Just wanted to confirm the working theory. I'm running OSX 10.10.5 and while attempting to rbenv install ruby-2.0.0-p481 I ran into this same issue. I checked and did have libz stuff in both /usr/local/lib and in /usr/lib. Removing the /usr/local/lib stuff was the only change I made and this allowed the install to succeed. I got this MacBook through the company and there was a version of Ruby pre-installed by root as well as a whole slew of other software. I have no way of tracing where the /usr/local/lib stuff came from.

Had the same issue on OSX 10.10.5, found stuff with ls /usr/local/lib/libz* and removed it, retried the install of rbenv install 2.2.4 and everything worked

The same worked for me as well installing 2.3.1. In case it's helpful, here is the full log of the original failure

i was having the same issue. I had files in /usr/local/lib/libz* and /usr/lib/libz*. I moved the files from /usr/local/lib/ and it worked. Thanks

/usr/local/lib/libz*
-rw-r--r-- 1 root wheel 99184 Apr 12 2016 /usr/local/lib/libz.1.2.5.dylib
-rw-r--r-- 1 root wheel 95312 Oct 19 20:51 /usr/local/lib/libz.1.2.6.dylib
-rw-r--r-- 1 root wheel 95312 Oct 19 20:51 /usr/local/lib/libz.1.dylib
-rw-r--r-- 1 root wheel 95312 Oct 19 20:51 /usr/local/lib/libz.dylib

/usr/lib/libz*
lrwxr-xr-x 1 root wheel 16 Feb 18 2014 /usr/lib/libz.1.1.3.dylib -> libz.1.2.5.dylib
-rwxr-xr-x 1 root wheel 169392 Feb 18 2014 /usr/lib/libz.1.2.5.dylib
lrwxr-xr-x 1 root wheel 16 Feb 18 2014 /usr/lib/libz.1.dylib -> libz.1.2.5.dylib
lrwxr-xr-x 1 root wheel 16 Feb 18 2014 /usr/lib/libz.dylib -> libz.1.2.5.dylib

macOS 10.9 is EOL status by Apple. We can't investigate this continuously in 2017.

I had the issue on 10.10.5, just sayin. I think people who come across this can just follow the same steps to remove the libz stuff and carry on with their lives

Had the same issue in 10.12.3. Removing the libz* files under usr/local/lib/ fixed it for me.

Had this problem in 10.12.6

I removed the libz* files under usr/local/lib/ and am now able to carry on with my life.

Was this page helpful?
0 / 5 - 0 ratings