8

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?

  • Is rvm path is in root's PATH? – cuonglm Aug 21 '14 at 2:29
  • rvm is in $PATH. I am not sure what you mean by "root's PATH". are there other's PATH? – Tim Aug 21 '14 at 2:31
  • I mean PATH when you are root. – cuonglm Aug 21 '14 at 2:34
  • It is not. Will it work if I switch to root, and add rvm path to the root's PATH by PATH=$PATH:/home/tim/.rvm/bin? I will have to switch back to my account, and install pdfbeads. – Tim Aug 21 '14 at 2:42
  • Shall I install rvm and ruby under the home of the root? – Tim Aug 21 '14 at 2:55
6

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:

21:59:48 durrantm Castle2012 /home/durrantm 
$ rvm list

rvm rubies

   ruby-1.8.7-p374 [ x86_64 ]
   ruby-1.9.3-p125 [ x86_64 ]
   ruby-1.9.3-p194 [ x86_64 ]
   ruby-1.9.3-p448 [ x86_64 ]
   ruby-2.0.0-p195 [ x86_64 ]
=* ruby-2.0.0-p247 [ x86_64 ]
   ruby-2.0.0-p481 [ x86_64 ]
   ruby-2.1.1 [ x86_64 ]
   ruby-2.1.2 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

21:59:50 durrantm Castle2012 /home/durrantm 
$ rvm use 2.0.0
Using /home/durrantm/.rvm/gems/ruby-2.0.0-p481

$ rvm use 2.1.1
Using /home/durrantm/.rvm/gems/ruby-2.1.1

$ rvm use 1.9.3
ruby-1.9.3-p547 is not installed.

$ rvm use 1.9.3-p448
Using /home/durrantm/.rvm/gems/ruby-1.9.3-p448

Get rvm at http://rvm.io/

Install with its famous 1 liner:

$ \curl -sSL https://get.rvm.io | bash -s stable

  • Thanks. I am now trying what you suggest. Btw, ruby1.9.3 is a symlink, linking to 1.9.1. Bu why it says itself is 1.9.3? – Tim Aug 21 '14 at 2:12
  • Why is ruby1.9.3 I installed not working? – Tim Aug 21 '14 at 2:19
  • Still get "nokogiri requires Ruby version >= 1.9.2" error, after installing ruby 2.1.0. I update my post at its end. – Tim Aug 21 '14 at 2:23
1

Install RVM and use the following:

rvm install 1.9.3
rvm use 1.9.3 --default
gem install pdfbeads  # Avoid sudo, will not fix real problems here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.