Cannot install chef from gem

I got the following error when I tried to install chef through gem. I was following this link to begin my journey for learning chef:

[root@jasontest bin]# gem install chef
ERROR: Error installing chef:
mixlib-shellout requires Ruby version >= 2.2.
[root@jasontest bin]# which ruby
[root@jasontest bin]# ruby --version
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
[root@jasontest bin]# which gem
[root@jasontest bin]# gem --version
[root@jasontest bin]# gem --help
RubyGems is a sophisticated package manager for Ruby. This is a
basic help message containing pointers to more information.

gem -h/–help
gem -v/–version
gem command [arguments…] [options…]

gem install rake
gem list --local
gem build package.gemspec
gem help install

Further help:
gem help commands list all ‘gem’ commands
gem help examples show some examples of usage
gem help platforms show information about platforms
gem help show help on COMMAND
(e.g. ‘gem help install’)
gem server present a web page at
with info about installed gems
Further information:
[root@jasontest bin]# pwd

Please run gem environment and report back on the output.

Thanks for your reply, here is the result:

[root@jasontest bin]# gem environment

RubyGems Environment:


  • RUBY VERSION: 2.0.0 (2015-12-16 patchlevel 648) [x86_64-linux]

  • INSTALLATION DIRECTORY: /usr/local/share/ruby/gems/2.0

  • RUBY EXECUTABLE: /usr/bin/ruby2.0

  • EXECUTABLE DIRECTORY: /usr/local/bin


  • ruby

  • x86_64-linux


  • /usr/local/share/ruby/gems/2.0

  • /root/.gem/ruby/2.0

  • /usr/share/ruby/gems/2.0


  • :update_sources => true

  • :verbose => true

  • :backtrace => false

  • :bulk_threshold => 1000



[root@jasontest bin]#

I noticed that the gem still uses the old version of Ruby which locates under /usr/bin/ruby2.0. Is there a way I can modify this?

RUBY EXECUTABLE: /usr/bin/ruby2.0

So there you go. It looks like you installed Ruby 2.0 at some point, and then 2.4 on top of that but in a way that didn’t overwrite the gem executable. You’ll need to fix that :slight_smile: The RUBY EXECUTABLE should match which ruby in most cases.

then how could I update the gem executable to use the newer version of ruby, do I need reinstall all the ruby or I can just update the gem configuration to overwrite the old ruby path?

How did you install Ruby 2.4 on your system?

You can find manual install instructions for Rubygems at Basically download the latest package, unpack, run ruby setup.rb and it should probably just work? Check if maybe your 2.4 version of gem ended up in /usr/local/bin or something though, might be a shadowing problem.

I will try it after lunch, thank you.