Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"constant Chef::Resource::Lxc not defined" with Chef < 11.6.0 #37

Open
StephenKing opened this issue Aug 4, 2013 · 1 comment
Open

Comments

@StephenKing
Copy link

After adding lxc to my run list, the following error occurred:

NameError
---------
constant Chef::Resource::Lxc not defined

Upgrading from 11.4.2 to Chef 11.6.0 solved this issue (did not test 11.4.4).

I'm not sure, if you want to make the cookbook compatible with older versions of Chef - I just wanted to report this in order to help people who run into the same issue (thus feel free to reject it immediately)

Details:

================================================================================
Recipe Compile Error in /var/chef/cache/cookbooks/lxc/resources/default.rb
================================================================================


NameError
---------
constant Chef::Resource::Lxc not defined


Cookbook Trace:
---------------
  /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.2/lib/chef/resource/lwrp_base.rb:43:in `remove_const'
  /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.2/lib/chef/resource/lwrp_base.rb:43:in `build_from_file'
  /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.2/lib/chef/run_context/cookbook_compiler.rb:208:in `load_lwrp_resource'
  /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.2/lib/chef/run_context/cookbook_compiler.rb:193:in `block in load_lwrps_from_cookbook'
  /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.2/lib/chef/run_context/cookbook_compiler.rb:192:in `each'
  /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.2/lib/chef/run_context/cookbook_compiler.rb:192:in `load_lwrps_from_cookbook'
  /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.2/lib/chef/run_context/cookbook_compiler.rb:120:in `block in compile_lwrps'
  /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.2/lib/chef/run_context/cookbook_compiler.rb:119:in `each'
  /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.2/lib/chef/run_context/cookbook_compiler.rb:119:in `compile_lwrps'
  /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.2/lib/chef/run_context/cookbook_compiler.rb:72:in `compile'
  /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.2/lib/chef/run_context.rb:86:in `load'
  /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.2/lib/chef/client.rb:224:in `setup_run_context'
  /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.2/lib/chef/client.rb:467:in `do_run'
  /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.2/lib/chef/client.rb:200:in `run'
  /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.2/lib/chef/application.rb:190:in `run_chef_client'
  /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.2/lib/chef/application/client.rb:297:in `block in run_application'
  /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.2/lib/chef/application/client.rb:290:in `loop'
  /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.2/lib/chef/application/client.rb:290:in `run_application'
  /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.2/lib/chef/application.rb:73:in `run'
  /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.2/bin/chef-client:26:in `<top (required)>'
  /usr/bin/chef-client:23:in `load'
  /usr/bin/chef-client:23:in `<main>'


Relevant File Content:
----------------------
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.2/lib/chef/resource/lwrp_base.rb:

 36:        # Evaluates the LWRP resource file and instantiates a new Resource class.
 37:        def self.build_from_file(cookbook_name, filename, run_context)
 38:          rname = filename_to_qualified_string(cookbook_name, filename)
 39:
 40:          # Add log entry if we override an existing light-weight resource.
 41:          class_name = convert_to_class_name(rname)
 42:          if Resource.const_defined?(class_name)
 43>>           old_class = Resource.send(:remove_const, class_name)
 44:            # CHEF-3432 -- Chef::Resource keeps a list of subclasses; need to
 45:            # remove old ones from the list when replacing.
 46:            resource_classes.delete(old_class)
 47:            Chef::Log.info("#{class_name} light-weight resource already initialized -- overriding!")
 48:          end
 49:
 50:          resource_class = Class.new(self)
 51:
 52:          resource_class.resource_name = rname
@chrisroberts
Copy link
Contributor

Is this issue presenting on the latest release?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants