Jake
Jake

Reputation: 73

Can't install Ruby Gems - gives a zlib error


Whenever I try and install any ruby gem (trying to install rails), I get this error:

ERROR:  Loading command: update (LoadError)
    cannot load such file -- zlib
ERROR:  While executing gem ... (NoMethodError)
    undefined method `invoke_with_build_args' for nil:NilClass

I have tried everything I can think of; reinstalling ruby, trying different ruby versions, etc., but I keep getting this error.

I am currently using Ruby Version 2.3.1, and I am on mac os x 10.11 El Capitan. I am trying to install the rails gem on my system so that I can use it in all my projects.

Upvotes: 2

Views: 4855

Answers (3)

Tai
Tai

Reputation: 70

If installing gems you used:

sudo gem install nameOftheGem

problem could be that you only use sudo if the stack was installed as root, so try the same as above without sudo.

Upvotes: 0

sureshvignesh
sureshvignesh

Reputation: 170

Install zlib in your machine

rvm get head
rvm pkg remove
rvm requirements run force
rvm reinstall 1.9.3-p374

Upvotes: 1

Khanh Pham
Khanh Pham

Reputation: 2973

I guess that you missed zlib package if you are using rvm. https://rvm.io/packages/zlib/

Update:

I have two options, you can try one of them.

Option1:

Copy and paste this command to your console:

rvm pkg install zlib
rvm autolibs rvm_pkg

Option 2:

You need to install the zlib development headers.

xcode-select --install

Then reinstall your gem.

Upvotes: 0

Related Questions