mostamazingname
mostamazingname

Reputation: 153

Rails install fails - cause by Nokogiri gem?

I am trying to setup a ruby on rails environment on my mac in order to start using the RubyMine IDE. I have used homebrew, rbenv and all other required libraries in order to install ruby/rails - however when I sudo gem install rails the install fails due to :

Building native extensions.  This could take a while...
ERROR:  Error installing rails:
    ERROR: Failed to build gem native extension.

    current directory: /usr/local/lib/ruby/gems/2.3.0/gems/nokogiri-1.6.8.1/ext/nokogiri
/usr/local/opt/ruby/bin/ruby -r ./siteconf20161110-767-xwnfls.rb extconf.rb
checking if the C compiler accepts ... yes
checking if the C compiler accepts -Wno-error=unused-command-line-argument-hard-error-in-future... no
Building nokogiri using packaged libraries.
Using mini_portile version 2.1.0
checking for iconv.h... yes
checking for gzdopen() in -lz... no
zlib is missing; necessary for building libxml2
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

I have tried to install Nokogiri on it's own and I get the following error:

ERROR:  While executing gem ... (Errno::EACCES)
    Permission denied @ rb_sysopen - /usr/local/lib/ruby/gems/2.3.0/gems/nokogiri-1.6.8.1/.autotest

I really hope somebody can help me as I am quite a noob to RonR and I feel like things have gotten messy directory/permission wise,

Thank you.

Upvotes: 0

Views: 650

Answers (1)

David S.
David S.

Reputation: 730

Let's take a quick look at a small part of the error that you have provided us.

zlib is missing; necessary for building libxml2

It's trying to tell you that you do not have zlib, so let's get it. Since you said you're using a Mac, I would install a package manager like Homebrew. Try doing brew install zlib to install this package.

Additionally, if you're starting out learning Ruby, regardless of what platform you are using, it might be helpful to use something like rbenv or rvm to manage different versions of Ruby and the gems that go along with those versions. You will run into less permissions issues (e.g. having to run gem install as a privileged user), some of which may be easy to solve, but some of which may send you down a rabbit hole for a few hours.

Upvotes: 1

Related Questions