How to fix "load error" for ohai in irb

#1

I am using a Mac OS 10.14.x and have ruby installed via brew.

I am trying to load ohai in irb:-

Craigs-MBP:~ craig$ irb
irb(main):001:0> require 'ohai'
LoadError: cannot load such file -- ohai
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in require' from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:inrequire'
from (irb):1
from /usr/bin/irb:11:in `<main>'

I therefore tried to install the gem, but apparently wrong ruby version:

ERROR: Error installing ohai:
mixlib-cli requires Ruby version >= 2.4.

So I installed Chef WS which installed Ruby 2.6.2.
However, after that same problem.

My gem env shows:-

RubyGems Environment:

  • RUBYGEMS VERSION: 2.5.2.3
  • RUBY VERSION: 2.3.7 (2018-03-28 patchlevel 456) [universal.x86_64-darwin18]
  • INSTALLATION DIRECTORY: /Library/Ruby/Gems/2.3.0
  • USER INSTALLATION DIRECTORY: /Users/craig/.gem/ruby/2.3.0
  • RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby
  • EXECUTABLE DIRECTORY: /usr/local/bin
  • SPEC CACHE DIRECTORY: /Users/craig/.gem/specs
  • SYSTEM CONFIGURATION DIRECTORY: /Library/Ruby/Site
  • RUBYGEMS PLATFORMS:
    • ruby
    • universal-darwin-18
  • GEM PATHS:
    • /Library/Ruby/Gems/2.3.0
    • /Users/craig/.gem/ruby/2.3.0
    • /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/gems/2.3.0
  • GEM CONFIGURATION:
    • :update_sources => true
    • :verbose => true
    • :backtrace => false
    • :bulk_threshold => 1000
  • REMOTE SOURCES:
  • SHELL PATH:
    • /usr/local/bin
    • /usr/bin
    • /bin
    • /usr/sbin
    • /sbin

Can anyone help me understand the problem and fix it please?

0 Likes