I install a ruby package.
$ sudo gem install pdfbeads
ERROR: Error installing pdfbeads:
nokogiri requires Ruby version >= 1.9.2.
says that it needs ruby version greater than 1.9.1.
My ruby is 1.8.7.
$ which ruby
/usr/bin/ruby
$ ruby --version
ruby 1.8.7 (2011-06-30 patchlevel 352) [i686-linux]
$ gem --version
1.8.15
I have ruby 1.9.1 and 1.9.3.
$ whereis ruby1.9.1
ruby1.9: /usr/bin/ruby1.9.1 /usr/bin/ruby1.9.3 /usr/bin/X11/ruby1.9.1 /usr/bin/X11/ruby1.9.3
but 1.9.3 is linked to 1.9.1.
$ ls /usr/bin/ruby* -l
lrwxrwxrwx 1 root root 22 Jul 10 02:33 /usr/bin/ruby -> /etc/alternatives/ruby
-rwxr-xr-x 1 root root 5504 Nov 26 2013 /usr/bin/ruby1.8
-rwxr-xr-x 1 root root 5552 Nov 26 2013 /usr/bin/ruby1.9.1
lrwxrwxrwx 1 root root 9 Nov 26 2013 /usr/bin/ruby1.9.3 -> ruby1.9.1
It says itself is 1.9.3 however:
$ /usr/bin/ruby1.9.3 --version
ruby 1.9.3p0 (2011-10-30 revision 33570) [i686-linux]
I change the link to ruby1.9.3 anyway
$ ls -l /usr/bin/ruby*
lrwxrwxrwx 1 root root 9 Aug 20 21:16 /usr/bin/ruby -> ruby1.9.3
-rwxr-xr-x 1 root root 5504 Nov 26 2013 /usr/bin/ruby1.8
-rwxr-xr-x 1 root root 5552 Nov 26 2013 /usr/bin/ruby1.9.1
lrwxrwxrwx 1 root root 9 Nov 26 2013 /usr/bin/ruby1.9.3 -> ruby1.9.1
The installation still says it needs ruby >= 1.9.2
$ sudo gem install pdfbeads
ERROR: Error installing pdfbeads:
nokogiri requires Ruby version >= 1.9.2.
$ gem --version
1.8.15
$ ruby --version
ruby 1.9.3p0 (2011-10-30 revision 33570) [i686-linux]
Do I have ruby1.9.3 or just ruby1.9.1?
How can I make sudo gem install pdfbeads
use ruby 1.9.3?
Update:
I have now followed the way of installing ruby 2.1.0 by RVM,
I have added the path of rvm
to my PATH
.
I then successfully installed ruby2.1.0 by
$ rvm install 2.1.0
and made it default
$ rvm use 2.1.0
$ ruby -v
ruby 2.1.0p0 (2013-12-25 revision 44422) [i686-linux]
$ which ruby
/home/tim/.rvm/rubies/ruby-2.1.0/bin/ruby
Now back to install the package pdfbeads
, but without sudo
(because I thought I had installed ruby 2.1.0 under my account, not under root, and installation of the package requires the newer version ruby)
$ gem install pdfbeads
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions into the /var/lib/gems/1.8 directory.
So I think I have to use sudo
. But I still get the original error,
$ sudo gem install pdfbeads
ERROR: Error installing pdfbeads:
nokogiri requires Ruby version >= 1.9.2.
I think it is because under sudo
, the user is root
, which still has the older version ruby1.8.7 as the default. So I wonder what can I do now?
Best Answer
You may wish to consider using a ruby package manager like rvm or rbenv
You can install different rubies and switch between them easily.
You might also want to consider trying 2.0+
Sample output from rvm:
Get rvm at http://rvm.io/
Install with its famous 1 liner:
$
\curl -sSL https://get.rvm.io | bash -s stable