Search code examples
rubyrubygemsgemfile

Could not find a valid gem 'metaclass'


My test did not run because 'mocha' was missing so I added to my Gemfile:

source "https://rubygems.org"
gem 'mocha'

Then I got:

Error installing mocha:
[14:47:00][Step 2/4]    mocha requires metaclass (~> 0.0.1, runtime)

So I added to my Gemfile:

source "https://rubygems.org"
gem 'metaclass'

And then I get:

Could not find a valid gem 'metaclass' (>= 0) in any repository

my ruby and os:

# ruby --version
ruby 1.8.7 (2013-06-27 patchlevel 374) [x86_64-linux]
# cat /etc/centos-release 
CentOS release 6.6 (Final)

What am I missing please?


Solution

  • Ruby 1.8.7 is your problem. It's been retired more than 3 years ago.

    You need a newer Ruby version (most recent one is 2.4).

    It shouldn't be a big problem with RVM. Here's a tutorial for CentOS.