# Cannot install chef from gem

**URL:** <https://discourse.chef.io/t/cannot-install-chef-from-gem/13309>\
**Category:** Chef Infra (archive)\
**Created:** [July 16, 2018, 8:52pm UTC](https://discourse.chef.io/t/cannot-install-chef-from-gem/13309 "2018-07-16T20:52:49Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![condescendent](https://avatars.discourse-cdn.com/v4/letter/c/b5ac83/32.png) [@condescendent](https://discourse.chef.io/u/condescendent)\
**Post date:** [July 16, 2018, 8:52pm UTC](https://discourse.chef.io/t/cannot-install-chef-from-gem/13309/1 "2018-07-16T20:52:49Z")

</div>

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: [https://www.tutorialspoint.com/chef/chef\_client\_setup.htm](https://www.tutorialspoint.com/chef/chef_client_setup.htm).

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

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

Examples:  
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  
[http://localhost:8808/](http://localhost:8808/)  
with info about installed gems  
Further information:  
[http://guides.rubygems.org](http://guides.rubygems.org)  
[root@jasontest bin]# pwd

---

<div class="post-metadata">

**Author:** ![coderanger](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/coderanger/32/5_2.png) [@coderanger](https://discourse.chef.io/u/coderanger)\
**Post date:** [July 16, 2018, 8:56pm UTC](https://discourse.chef.io/t/cannot-install-chef-from-gem/13309/2 "2018-07-16T20:56:52Z")

</div>

Please run `gem environment` and report back on the output.

---

<div class="post-metadata">

**Author:** ![condescendent](https://avatars.discourse-cdn.com/v4/letter/c/b5ac83/32.png) [@condescendent](https://discourse.chef.io/u/condescendent)\
**Post date:** [July 16, 2018, 9:25pm UTC](https://discourse.chef.io/t/cannot-install-chef-from-gem/13309/3 "2018-07-16T21:25:50Z")

</div>

Thanks for your reply, here is the result:

[root@jasontest bin]# gem environment

RubyGems Environment:

- RUBYGEMS VERSION: 2.0.14.1

- 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

- RUBYGEMS PLATFORMS:

- ruby

- x86\_64-linux

- GEM PATHS:

- /usr/local/share/ruby/gems/2.0

- /root/.gem/ruby/2.0

- /usr/share/ruby/gems/2.0

- GEM CONFIGURATION:

- :update\_sources =\> true

- :verbose =\> true

- :backtrace =\> false

- :bulk\_threshold =\> 1000

- REMOTE SOURCES:

- [https://rubygems.org/](https://rubygems.org/)

[root@jasontest bin]#

---

<div class="post-metadata">

**Author:** ![condescendent](https://avatars.discourse-cdn.com/v4/letter/c/b5ac83/32.png) [@condescendent](https://discourse.chef.io/u/condescendent)\
**Post date:** [July 16, 2018, 9:27pm UTC](https://discourse.chef.io/t/cannot-install-chef-from-gem/13309/4 "2018-07-16T21:27:41Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![coderanger](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/coderanger/32/5_2.png) [@coderanger](https://discourse.chef.io/u/coderanger)\
**Post date:** [July 16, 2018, 9:28pm UTC](https://discourse.chef.io/t/cannot-install-chef-from-gem/13309/5 "2018-07-16T21:28:12Z")

</div>

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 🙂 The `RUBY EXECUTABLE` should match `which ruby` in most cases.

---

<div class="post-metadata">

**Author:** ![condescendent](https://avatars.discourse-cdn.com/v4/letter/c/b5ac83/32.png) [@condescendent](https://discourse.chef.io/u/condescendent)\
**Post date:** [July 16, 2018, 9:30pm UTC](https://discourse.chef.io/t/cannot-install-chef-from-gem/13309/6 "2018-07-16T21:30:22Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![coderanger](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/coderanger/32/5_2.png) [@coderanger](https://discourse.chef.io/u/coderanger)\
**Post date:** [July 16, 2018, 9:34pm UTC](https://discourse.chef.io/t/cannot-install-chef-from-gem/13309/7 "2018-07-16T21:34:01Z")

</div>

How did you install Ruby 2.4 on your system?

---

<div class="post-metadata">

**Author:** ![coderanger](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/coderanger/32/5_2.png) [@coderanger](https://discourse.chef.io/u/coderanger)\
**Post date:** [July 16, 2018, 9:36pm UTC](https://discourse.chef.io/t/cannot-install-chef-from-gem/13309/8 "2018-07-16T21:36:22Z")

</div>

You can find manual install instructions for Rubygems at [https://rubygems.org/pages/download](https://rubygems.org/pages/download). 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.

---

<div class="post-metadata">

**Author:** ![condescendent](https://avatars.discourse-cdn.com/v4/letter/c/b5ac83/32.png) [@condescendent](https://discourse.chef.io/u/condescendent)\
**Post date:** [July 16, 2018, 10:15pm UTC](https://discourse.chef.io/t/cannot-install-chef-from-gem/13309/9 "2018-07-16T22:15:27Z")

</div>

I will try it after lunch, thank you.
