Skip to content

Instantly share code, notes, and snippets.

@mindreframer
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mindreframer/9052527 to your computer and use it in GitHub Desktop.
Save mindreframer/9052527 to your computer and use it in GitHub Desktop.
fixing not required libraries for chef
## to fix lib dependency, put this on top of your recipe file.
self.run_context.cookbook_collection[self.cookbook_name].library_filenames.each { |e| load(e) }
## in a cookbook, that needs my_cookbook
## in metadata.rb
depends 'my_cookbook'
# my_cookbook/libraries/helpers.rb
module MyCookbook
module Helpers
def foo
"foo"
end
end
end
# my_cookbook/recipes/default.rb
##self.run_context.cookbook_collection[self.cookbook_name].library_filenames.each { |e| load(e) }
extend ::MyCookbook::Helpers # this would not work without the line above. maybe something wrong with my chef version
raise foo.inspect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment