gem install rails - can't install

Hi, I have a rhel7 system and am trying to install the rails gem, I was wondering how to troubleshoot this since I don't see any useful error message. I'm guessing i'm just missing something, how to see what it might be?

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

    /usr/bin/ruby extconf.rb checking if the C compiler accepts ... yes Building nokogiri using packaged libraries. Using mini_portile version 2.0.0 checking for gzdopen() in -lz... yes checking for iconv... yes

I think you are missing something that is required to build nokigiri. I generally recommend using rvm to install ruby and rails, as rvm will install all the requirements for you and will help you to manage different versions of ruby and rails, but I don't know about using rvm with rhel7. On ubuntu this would be as simple as

gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 \curl -L https://get.rvm.io | bash -s stable --rails

See rvm.io

Colin

My hypothesis would be missing headers and libraries for libxml2, libxslt or ruby. What's inside mkmf.log?

# rpm -qa |grep libxml2 libxml2-python-2.9.1-6.el7_2.2.x86_64 libxml2-devel-2.9.1-6.el7_2.2.x86_64 libxml2-2.9.1-6.el7_2.2.x86_64

# rpm -qa |grep libxslt libxslt-1.1.28-5.el7.x86_64 libxslt-devel-1.1.28-5.el7.x86_64

# cat /usr/local/share/gems/gems/nokogiri-1.6.7.2/ext/nokogiri/mkmf.log

"gcc -o conftest -I/usr/include -I/usr/include/ruby/backward -I/usr/include -I. -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -mtune=generic -fPIC conftest.c -L. -L/usr/lib64 -L. -Wl,-z,relro -fstack-protector -rdynamic -Wl,-export-dynamic -m64 -lruby -lpthread -lrt -ldl -lcrypt -lm -lc " checked program was: /* begin */ 1: #include "ruby.h" 2: 3: int main(int argc, char **argv) 4: { 5: return 0; 6: } /* end */

"gcc -I/usr/include -I/usr/include/ruby/backward -I/usr/include -I. -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -mtune=generic -fPIC -m64 -Werror -c conftest.c" checked program was: /* begin */ 1: #include "ruby.h" 2: 3: int main() {return 0;} /* end */

have_library: checking for gzdopen() in -lz... -------------------- yes

"gcc -o conftest -I/usr/include -I/usr/include/ruby/backward -I/usr/include -I. -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -mtune=generic -fPIC -g -DXP_UNIX -Wall -Wcast-qual -Wwrite-strings -Wconversion -Wmissing-noreturn -Winline conftest.c -L. -L/usr/lib64 -L. -Wl,-z,relro -fstack-protector -rdynamic -Wl,-export-dynamic -m64 -lruby -lz -lpthread -lrt -ldl -lcrypt -lm -lc " conftest.c: In function 't': conftest.c:7:32: warning: variable 'p' set but not used [-Wunused-but-set-variable] int t(void) { void ((*volatile p)()); p = (void ((*)()))gzdopen; return 0; }                                 ^ checked program was: /* begin */ 1: #include "ruby.h" 2: 3: #include <zlib.h> 4: 5: /*top*/ 6: extern int t(void); 7: int t(void) { void ((*volatile p)()); p = (void ((*)()))gzdopen; return 0; } 8: int main(int argc, char **argv) 9: { 10: if (argc > 1000000) { 11: printf("%p", &t); 12: } 13: 14: return 0; 15: } /* end */

Did you run: sudo yum install -y rubygem-nokogiri before 'gem install nokogiri` ?

And sudo yum install -y gcc ruby-devel zlib-devel is recommended if you have problems.

source: Installing Nokogiri - Nokogiri

Thanks for everyone's help,

Since the problem seemed to be with nokogiri, I managed to get it to work with gem install nokogiri -- --use-system-libraries However since there is a RPM for it, I should try that too.