Error executing gem install rails

1

trying to install rails, after having installed ruby and rubygems, I try to execute the following command:

sudo gem install rails

which gives me the following error:

checking for gzdopen() in -lz... no
zlib is missing; necessary for building libxml2
*** extconf.rb failed ***

The command ends with an error and the gem is not finished.

    
asked by JorelC 01.02.2017 в 21:41
source

2 answers

1

This is due to certain dependencies or development libraries not installed. In debian-ubuntu systems you just have to execute the following command:

sudo apt-get install libxml2-dev zlib1g-dev

Previously we should have installed the develop ruby package:

sudo apt-get install ruby-dev

After this we can successfully execute the installation command of the rails gem:

sudo gem install rails
    
answered by 01.02.2017 / 21:41
source
0

Personally I do not recommend you to perform the installation using

sudo gem install rails

Since this will install a specific version of rails on your system and make it available, the future problem could be having to open an application in a different version of rails or even some gems, so it is recommended to use version handlers as rvm or rbenv

The reason for the error message is that ruby does not find some necessary libraries as prerequisites for rails, this is because ruby is a language that for performance reasons prefers to interact directly with the native libraries of the operating system.

You could solve it with:

sudo apt-get install libxml2-dev zlib1g-dev

If you are going to use a version manager as recommended, be sure to execute this command first so you do not have to install it later in the context of the version manager.

    
answered by 12.02.2017 в 14:43