Chef workstation: Can not find omnibus installation directory for Chef

597 views Asked by At

I just installed chef-workstation on mac, I also have rvm installed on my machine. The chef-workstation is successfully installed but when I try to run chef exec command it fails with below error -

Traceback (most recent call last):
20: from /Users/tusharhawaldar/.rvm/gems/ruby-2.6.0@base/bin/ruby_executable_hooks:22:in `<main>'
19: from /Users/tusharhawaldar/.rvm/gems/ruby-2.6.0@base/bin/ruby_executable_hooks:22:in `eval'
18: from /Users/tusharhawaldar/.rvm/gems/ruby-2.6.0@base/bin/chef:23:in `<main>'
17: from /Users/tusharhawaldar/.rvm/gems/ruby-2.6.0@base/bin/chef:23:in `load'
16: from /Users/tusharhawaldar/.rvm/gems/ruby-2.6.0@base/gems/chef-dk-3.11.3/bin/chef:25:in `<top (required)>'
15: from /Users/tusharhawaldar/.rvm/gems/ruby-2.6.0@base/gems/chef-dk-3.11.3/lib/chef-dk/cli.rb:73:in `run'
14: from /Users/tusharhawaldar/.rvm/gems/ruby-2.6.0@base/gems/chef-dk-3.11.3/lib/chef-dk/command/base.rb:58:in `run_with_default_options'
13: from /Users/tusharhawaldar/.rvm/gems/ruby-2.6.0@base/gems/chef-dk-3.11.3/lib/chef-dk/command/env.rb:39:in `run'
12: from /Users/tusharhawaldar/.rvm/gems/ruby-2.6.0@base/gems/chef-dk-3.11.3/lib/chef-dk/command/env.rb:39:in `tap'
11: from /Users/tusharhawaldar/.rvm/gems/ruby-2.6.0@base/gems/chef-dk-3.11.3/lib/chef-dk/command/env.rb:41:in `block in run'
10: from /Users/tusharhawaldar/.rvm/gems/ruby-2.6.0@base/gems/chef-dk-3.11.3/lib/chef-dk/command/env.rb:57:in `ruby_info'
 9: from /Users/tusharhawaldar/.rvm/gems/ruby-2.6.0@base/gems/chef-dk-3.11.3/lib/chef-dk/command/env.rb:57:in `tap'
 8: from /Users/tusharhawaldar/.rvm/gems/ruby-2.6.0@base/gems/chef-dk-3.11.3/lib/chef-dk/command/env.rb:60:in `block in ruby_info'
 7: from /Users/tusharhawaldar/.rvm/gems/ruby-2.6.0@base/gems/chef-dk-3.11.3/lib/chef-dk/command/env.rb:60:in `tap'
 6: from /Users/tusharhawaldar/.rvm/gems/ruby-2.6.0@base/gems/chef-dk-3.11.3/lib/chef-dk/command/env.rb:63:in `block (2 levels) in ruby_info'
 5: from /Users/tusharhawaldar/.rvm/gems/ruby-2.6.0@base/gems/chef-dk-3.11.3/lib/chef-dk/command/env.rb:69:in `gem_environment'
 4: from /Users/tusharhawaldar/.rvm/gems/ruby-2.6.0@base/gems/chef-dk-3.11.3/lib/chef-dk/command/env.rb:69:in `tap'
 3: from /Users/tusharhawaldar/.rvm/gems/ruby-2.6.0@base/gems/chef-dk-3.11.3/lib/chef-dk/command/env.rb:70:in `block in gem_environment'
 2: from /Users/tusharhawaldar/.rvm/gems/ruby-2.6.0@base/gems/chef-dk-3.11.3/lib/chef-dk/helpers.rb:124:in `omnibus_env'
 1: from /Users/tusharhawaldar/.rvm/gems/ruby-2.6.0@base/gems/chef-dk-3.11.3/lib/chef-dk/helpers.rb:72:in `omnibus_embedded_bin_dir'
/Users/tusharhawaldar/.rvm/gems/ruby-2.6.0@base/gems/chef-dk-3.11.3/lib/chef-dk/helpers.rb:142:in `omnibus_expand_path': Can not find omnibus installation directory for Chef. (ChefDK::OmnibusInstallNotFound)

When I checked for omnibus_root path it is giving -

/Users/tusharhawaldar/.rvm/rubies

And it is trying to find bin & /embedded/bin directories at omnibus_root_path, which are not present there, so it is raising this error.

I manually created these directories at omnibus_root_path, and I can now run the chef exec command, but when it run the chefspec it is now giving below error -

An error occurred while loading ./spec/unit/recipes/initial_packages_spec.rb.
Failure/Error: require 'chefspec'
LoadError:
  cannot load such file -- chefspec
  ./spec/spec_helper.rb:1:in `<top (required)>'
  ./spec/unit/recipes/initial_packages_spec.rb:1:in `<top (required)>'
No examples found.

require 'chefspec' is failing means something missing in setup, which I doubt is related to chef omnibus.

What should be the correct way to resolve error related to ChefDK::OmnibusInstallNotFound?

1

There are 1 answers

0
Tushar H On

Okay, so after trying various things, I finally found a solution for error -

Can not find omnibus installation directory for Chef. (ChefDK::OmnibusInstallNotFound)

And it is running below command for path update -

echo 'export PATH="/opt/chef-workstation/embedded/bin:$PATH"' >> ~/.bash_profile && source ~/.bash_profile

From - https://www.tutorialspoint.com/chef/chef_workstation_setup.htm

The Omnibus Chef will install Ruby and all the required Ruby gems into /opt/chef/embedded by adding /opt/chef/embedded/bin directory to the .bash_profile file.