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


#1

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’


#2

Is there any chance that you aren’t actually using ruby 1.9.3? I notice
that the method absolute_path was added to File in ruby 1.9.1, and the
error message seems to be saying that File.absolute_path isn’t a defined
method.

-Matt Moretti

On Thu, Jul 25, 2013 at 2:31 AM, David Montgomery <davidmontgomery@gmail.com

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’


#3

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 davidmontgomery@gmail.com 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’