Help regarding installation of Gems

Hello @colin when i tried to ru gem install nokogiri -v '1.6.6.2' -- --use-system-libraries --with-xml2-include=/usr/include/libxml2 --with-xml2-lib=/usr/lib command with out using Sudo i got this message-Error installing nokogiri:     ERROR: Failed to build gem native extension. Its kind of error that extconf.rb so after that i tried gem install rails but the same error. If Any mistake made by me then please help me to correct on this.

I am starting to run out of ideas, but before we use the sledgehammer approach, what is shown by the commands gem -v and which gem

Also what does this give you apt-cache policy libxml2

Colin

Hello colin as u told me to send some data relavant to your command let me give a Result of command that i tried

prasanna@prasanna-HP-Pavilion-dv6-Notebook-PC:~$ gem -v 2.4.8

prasanna@prasanna-HP-Pavilion-dv6-Notebook-PC:~$ which gem /home/prasanna/.rvm/rubies/ruby-2.2.3/bin/gem

prasanna@prasanna-HP-Pavilion-dv6-Notebook-PC:~$ apt-cache policy libxml2 libxml2: Installed: 2.9.1+dfsg1-3ubuntu4.4 Candidate: 2.9.1+dfsg1-3ubuntu4.4 Version table: *** 2.9.1+dfsg1-3ubuntu4.4 0 500 Index of /ubuntu trusty-updates/main amd64 Packages 500 Index of /ubuntu trusty-security/main amd64 Packages 100 /var/lib/dpkg/status 2.9.1+dfsg1-3ubuntu4 0 500 Index of /ubuntu trusty/main amd64 Packages

This is what all i got …

I notice that you have not followed my request to reply to the previous message when replying and insert your reply inline within or after the previous message so that it makes it easier to follow the thread. I offer support on a number of lists and anything you can do to make life easier for me will make it more likely that I will try to help. Thanks.

Those look a little odd, as I have just installed on a 14.04 system using rvm in a similar way to that in the tutorial you linked to and I have ended up with ruby 2.2.1 (not 2.2.3) and gem 2.4.6 (not 2.4.8). I don't know how you achieved that but it should not really matter.

However, all else having failed I think the only option is to use the sledgehammer. I suggest you entirely remove rvm by

rm -rf ~/.rvm* ~/.gem/ ~/.bundle Some of those may not exist so don't worry if it does not find them to delete.

Tell gem that we don't need to install the docs echo 'gem: --no-rdoc --no-ri' > ~/.gemrc

Remove the Ubuntu version of gem if you have somehow installed it sudo apt-get purge gem

Now install ruby and rails using rvm - Note never use sudo for installing rails related stuff except for installing system libraries and so on with apt-get. Otherwise you end up with things owned by root and in the wrong folders.

curl -L https://get.rvm.io | bash -s stable --rails

You might have to put your password in if rvm needs to install any system libraries or tools. If any errors are thrown up then let us know.

You should already have added the line to load rvm on login onto the end of .bashrc (as in the tutorial) so won't need to do that again.

logout and in again.

So now rvm notes rails -v ruby -v gem -v should all work and show versions picked up from the .rvm folder in your home directory.

Good luck

Colin

Please make sure you have also installed libxml2-dev, notice the suffix!

Please make sure you have also installed libxml2-dev, notice the suffix!

I believe that has already been checked earlier in the thread.

Colin

Sorry, that answer was to the wrong mail, because of some flaws of Google’s inbox mailclient.

In fact he only checked for libxml2, not for libxml2-dev as far as I understand ops answer.

Sorry, that answer was to the wrong mail, because of some flaws of Google's inbox mailclient.

In fact he only checked for libxml2, not for libxml2-dev as far as I understand ops answer.

In his post of 18th Sept

Though @coli u had told me to try out sudo apt-get install libxslt1-dev libxml2-dev command ,its working fine showing that

libxslt1-dev is already the newest version. libxml2-dev is already the newest version. 0 upgraded, 0 newly installed, 0 to remove and 490 not upgraded.

It is a bit odd that he does not seem to be keeping his system up to date (490 not upgraded), but I would think that is not likely to be an issue. However: @Prassanna unless you have a good reason you should keep your system up to date using the software updater or by sudo apt-get update && sudo apt-get dist-upgrade

Colin

Hello @colin …Though i know there are some issue in resolving installation .so can you please prefer me any video tutorial link that will be more fruitful for me…cause am a begineer so i dont want to take any risk…so please help me…Thanks

Hello @colin ..Though i know there are some issue in resolving installation .so can you please prefer me any video tutorial link that will be more fruitful for me..cause am a begineer so i dont want to take any risk..so please help me..Thanks

In my one of my posts yesterday I provided detailed instructions on how to remove rvm and start again. I also asked for, I believe, the third time, that you help to make it easier for me by inserting your reply at appropriate points in the previous posting, yet you continue to top post. Look back at the post yesterday on removing and installing with rvm again, read it and make sure you understand it. However, make sure that you follow my request to insert your replies at appropriate points in the previous message if you want me to help further.

If you don't understand what I mean by top posting and inserting replies inline then have a look at

Colin

I thought I would just chime in to say that I was (seemingly) having the same problem as described by Prasanna, and the “sledgehammer” approach described by Colin has solved it for me.

The first time I had tried installing rails, I was following the guide on Install Ruby On Rails on Ubuntu 14.04 Trusty Tahr | GoRails which prescribes calling,

curl -L https://get.rvm.io | bash -s stable

(without --rails), and calling “gem install rails” later. I’m not entirely sure why that borks things. My guess is that the script when called with --rails installs whatever magic package I was missing.

Cheers, Erik

There are 2 problems:

  1. Even though installing ruby seems possible without source files (eg ruby.h) using eg rvm, ruby-install etc, subsequently installing rails as a gem requires these files. To avoid version mismatch with the versions from your os (package manager eg yum, yast, apt) its best to build ruby from source.
  2. nokogiri seems to have a bug. Installing rails as a ruby gem fails because of nokogiri wanting to bring in its own version of some dev fies (eg libxml2, libxslt). So you should install nokogiri separately first explicitly telling it not to use these files.

Download Ruby - build from source

Make sure in your os package manager (yum, yast, apt etc) that you install any prerequisites for building c fies eg c compiler, make, etc

Additionally make sure the following are installed:

libxml2-devel, libxslt-devel (for nokogiri)

nodejs for runtime (server)

cd ~/declan/Downloads/ruby-2.2.3 #create dir below first manually as user “declan” otherwise they will automatically get created belonging to root ./configure --prefix=/home/declan/dev/web_framework/rails/ruby/2.2.3/ make sudo make install

``

Dowload and install “chruby” (GitHub - postmodern/chruby: Changes the current Ruby)

cd /home/declan/tmp/

wget -O chruby-0.3.9.tar.gz https://github.com/postmodern/chruby/archive/v0.3.9.tar.gz tar -xzvf chruby-0.3.9.tar.gz cd chruby-0.3.9/

``

install (to local dir … dont need sudo)

dont use setup.sh …see below

PREFIX=/home/declan/dev/web_framework/rails/chruby/0.3.9/ make install

``

!! dont do this since it adds a “chruby.h” file to /etc/profile.d/ which causes share/chruby/auto.sh to get run each system boot … dont want this

sudo /home/declan/tmp/chruby-0.3.9/scripts/setup.sh

by default installs to “/usr/local/share/chruby/”

edit chruby.sh to tell it about our custom ruby

/home/declan/dev/web_framework/rails/chruby/0.3.9/share/chruby/chruby.sh

RUBIES+=(“/home/declan/dev/web_framework/rails/ruby/2.2.3/”)

``

Now you have a clean locally installed version of rails (which is independent of any system version), which you can "activate via

source /home/declan/dev/web_framework/rails/chruby/0.3.9/share/chruby/chruby.sh chruby 2.2.3 ruby --version # 2.2.3

``

gem install rubygems-update # update gem itself

One should be able to install rails as a gem now, but apparently nokogiri bringing its own versions of files like libxml2-devel, libxslt-devel causes error messages like youre having, so manually install it first explicitly telling it not to use these:

gem install nokogiri – --use-system-libraries

``

Now install rails itself

gem install rails
rails --version Rails 4.2.4

``

Using rvm to install ruby and rails has always worked fine for me on various versions of Ubuntu. I have found no need to do otherwise.

Colin