[SOLVED] Chef client run show error: /usr/bin/chef-client:5:in `<main>': uninitialized constant Gem (NameError)


I have used chef server to bootstrap a node but it shows error:

/usr/bin/chef-client:5:in `': uninitialized constant Gem (NameError)

This is my ruby version on the node:

/opt/chef/embedded/bin/ruby -v
ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-linux]

chef-client version


But my other nodes got no problem when run the same version of chef-client and ruby.

My chef server output:

chef -v
Chef Development Kit Version: 2.3.4
chef-client version: 13.4.19
delivery version: master (73ebb72a6c42b3d2ff5370c476be800fee7e5427) 
berks version: 6.3.1
kitchen version: 1.17.0
inspec version: 1.36.1

rpm -qa | grep chef

The line 5 shows:

	head /usr/bin/chef-client
#!/opt/chefdk/embedded/bin/ruby --disable-gems
ENV["GEM_HOME"] = ENV["GEM_PATH"] = nil unless ENV["APPBUNDLER_ALLOW_RVM"] == "true"
require "rubygems"
-->	::Gem.clear_paths

gem "CFPropertyList", "= 2.3.5"
gem "activesupport", "= 4.2.9"

What caused this and how to troubleshoot? Thank you.


I solved the problem by installing chef-client version 14.2.0 on the client node. Don’t know why.