8

I'm try to install rails on Debian. when run this command

gem install rails

I gave this error:

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

even when I try this command: gem install I gave this error:

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

I used this link to build ruby from sources ruby 2.1.2 build instruction

what can I do to overcome this error?

blelump
  • 3,233
  • 1
  • 16
  • 20
Esterlinkof
  • 1,444
  • 3
  • 22
  • 27

2 Answers2

19

For who compile from source, they must checked dependencies. I think you need to install this library :

sudo apt-get install libssl-dev

Then you must recompiled ruby and everything worked.

einverne
  • 6,454
  • 6
  • 45
  • 91
3

You need to install the zlib development headers.

Refer to your OS's package manager instructions on how to do this.

On a RedHat derivative it would look something like this:

sudo yum install zlib-devel

For ubuntu:

sudo apt-get install zlib1g-dev

Hope this helps

ptierno
  • 9,534
  • 2
  • 23
  • 35
  • this isn't help. my zlib1g-dev already installed and it's version is: _i 1:1.2.7.dfsg-13_. is this version out of date ? – Esterlinkof Nov 15 '14 at 16:12
  • which method from your install link did you follow? `rbenv`, `rvm`, or `source`? – ptierno Nov 15 '14 at 16:48
  • I build ruby from source – Esterlinkof Nov 15 '14 at 17:03
  • please supply the full output of `dpkg -l | grep zlib`. Not sure why `ruby` isn't finding the headers. – ptierno Nov 15 '14 at 17:27
  • here is the output : ii zlib1g:amd64 1:1.2.7.dfsg-13 amd64 compression library - runtime ii zlib1g-dev:amd64 1:1.2.7.dfsg-13 amd64 compression library - development – Esterlinkof Nov 16 '14 at 15:57
  • the package in question is openssl-devel for CentOS. – crsuarezf Feb 17 '16 at 16:41
  • Installed `ruby-2.1.9` from source on `ubuntu 14.04 LTS` `dpkg -l | grep zlib` `ii zlib1g:amd64 1:1.2.8.dfsg-1ubuntu1 amd64 compression library - runtime` `ii zlib1g-dev:amd64 1:1.2.8.dfsg-1ubuntu1 amd64 compression library - development` – Sharath Mar 10 '16 at 03:54