29

I get the error

Error installing jekyll:
jekyll requires Ruby version >= 2.0.0.

when I run

sudo gem install jekyll

"ruby -v" says I have ruby version 1.9.3

How do I install Jekyll? Do I need to upgrade ruby? If so, how?

Update - I installed ruby 2.0.0 with rvm but get the same error. Since trying to install with gem, could that still be trying to install with the older version of ruby? If so, how to find and change?

faehnrich
  • 331
  • 1
  • 3
  • 7
  • 1
    By updating your Ruby, the "how" depends on how you're managing your Ruby versions. – Dave Newton Nov 03 '15 at 16:11
  • How does one manage ruby versions? – faehnrich Nov 03 '15 at 16:13
  • 1
    System-level install, Installer install, rvm, rbenv, ... – Dave Newton Nov 03 '15 at 16:17
  • 3
    Installed ruby 2.0.0 but still getting the same error. Could gem be still using the older version? – faehnrich Nov 03 '15 at 16:25
  • 1
    [this answer](http://stackoverflow.com/a/34523631/4233593) was very helpful for installing the ruby version manager, which allows you to checkout and use any version you want whenever you want in your home environment without need for `sudo`, simply run `gem install jekyll` – Jeff Puckett Jul 24 '16 at 04:15
  • I have the same problem. Trying to follow all the recommendations using rbenv and bundler. The final `bundle install` fails with this "requires Ruby version >= 2.0.0." despite `rbenv version` giving `2.3.1 (set by /vagrant/.ruby-version)`. Here's a bash script within a vagrant file: http://pastebin.com/UTgmRQfF – Harry Wood Oct 05 '16 at 00:43

5 Answers5

40

Try

sudo gem install jekyll -v 2.5

The default command apparently tries to install Jekyll 3, which was released on October 27th 2015. The 2.5 version still works with Ruby 1.9.3, and its quite allright for me, probably for you too.

Pavel Shorokhov
  • 4,485
  • 1
  • 35
  • 44
hectorh30
  • 763
  • 1
  • 6
  • 12
  • [this answer](http://stackoverflow.com/a/34523631/4233593) was very helpful for installing the ruby version manager, which allows you to checkout and use the newest or any version you want whenever you want in your home environment without need for `sudo`, simply run `gem install jekyll` – Jeff Puckett Jul 24 '16 at 04:15
  • According to some old help on Jekyll's issue page the Ubuntu package is "incredibly old" and you shouldn't use it. https://github.com/jekyll/jekyll-help/issues/209 – geneorama Jul 25 '16 at 20:52
15

I solved this issue the following way (assuming the ruby2.0 package is installed):

sudo rm /usr/bin/ruby
sudo rm /usr/bin/gem
sudo ln -s /usr/bin/ruby2.0 /usr/bin/ruby
sudo ln -s /usr/bin/gem2.0 /usr/bin/gem

Quick explanation:

/usr/bin/ruby and /usr/bin/gem are symlinks, you can check their target by entering:

ll /usr/bin/ruby
ll /usr/bin/gem 

Changing the target of these links results in changing your default ruby and gem execution. Switching to version 2.0 for instance, lets you install Jekyll 3.

Martin R.
  • 1,554
  • 17
  • 16
  • This solution will break your packaging system, and might in the future make it impossible for you to upgrade. Bad solution, do not do this. – opentokix Apr 18 '16 at 11:53
  • Could you elaborate? Why is it breaking the packaging system? Also, you could always switch the symbolic links to their original target easily. – Martin R. Apr 18 '16 at 13:39
  • 2
    You should never mess around under /usr /usr/bin etc. - Thats what /usr/local/ is for. You could do ln -s /usr/bin/ruby2.0 /usr/local/bin/ruby That would be the correct debian-way, if you are going to mess around with symlinks. – opentokix Apr 27 '16 at 09:11
  • Imho having different symlinks, from different locations, to different ruby versions is the messier of the two solutions. And I still don't see why the packaging system would be broken. – Martin R. Apr 27 '16 at 12:16
  • Other solutions seems pretty easy and safe to me. – Arpit Solanki Mar 27 '17 at 18:05
13

You can give a try to:

sudo apt-get install ruby2.0 ruby2.0-dev
sudo gem2.0 install jekyll-import 
lrkwz
  • 6,105
  • 3
  • 36
  • 59
  • I had a similar stack trace like above question, it was for sass package while building in `travis-ci` 's `trusty`. Using above and doing `apt-get install build-essential` before helped. –  Oct 24 '17 at 05:04
4

I try the following on Ubuntu 14.04:

sudo apt-get install ruby2.0 ruby2.0-dev
sudo apt-get install zlib1g-dev
sudo gem2.0 install jekyll
mathsyouth
  • 3,770
  • 1
  • 20
  • 18
1

If you've already installed a later version of Ruby AND you're using rbenv, and gem gives the same error, it is because you are still using the old version of gem. There are now two executables called gem in your filesystem. Figure out which gem is the default with "which":

$ which gem

If you see something like */.rbenv/shims/gem, this is not the version of gems that you want to use. The correct version of gem will be in /.rbenv/versions/[your preferred version, i.e. 2.0.0]. You can run that version of gem by including the full path to the executable:

$ sudo /path/to/correct/gem install jekyll