[chef] Re: Chef Solo - Unknown error processing config file with error undefined method `absolute_path' for File:Class


Chronological Thread 
  • From: Maciej Pasternacki < >
  • To:
  • Subject: [chef] Re: Chef Solo - Unknown error processing config file with error undefined method `absolute_path' for File:Class
  • Date: Thu, 25 Jul 2013 21:19:29 +0200

David,

solo.rb (and other Chef configs) are executed inside an anonymous class, to improve isolation between configuration and Ruby world, and prevent conflicts between settings and methods on Kernel module and Object class. Try fully qualifying the File class:

    root = ::File.absolute_path(::File.dirname(__FILE__))

I remember that when I was writing active code for knife.rb, solo.rb, etc, I always needed to fully qualify classes.

HTH,
-- Maciej


On 25 July 2013 08:31, David Montgomery < " target="_blank"> > wrote:
Why wil chef solo not run?  I am using ruby 1.9.3

My cookbooks are in

/home/ubuntu/workspace/predictivematch-chef/chef-repo/cookbooks

chef-solo -c /home/ubuntu/workspace/chef-repo/solo.rb -j /home/ubuntu/workspace/chef-repo/roles/local_server.json
[2013-07-25T14:24:36+08:00] FATAL: Unknown error processing config file  with error undefined method `absolute_path' for File:Class

Below is my chef-solo file

root = File.absolute_path(File.dirname(__FILE__))
file_cache_path root

cookbook_path root + '/cookbooks'
data_bag_path root + '/data_bags'

file_cache_path = '/var/chef/cache'
Chef::Config[:file_cache_path]= '/var/chef/cache'




Archive powered by MHonArc 2.6.16.

§