# Malformed array causing Chef to error out

**URL:** <https://discourse.chef.io/t/malformed-array-causing-chef-to-error-out/6354>\
**Category:** Chef Infra (archive)\
**Created:** [February 26, 2015, 5:40pm UTC](https://discourse.chef.io/t/malformed-array-causing-chef-to-error-out/6354 "2015-02-26T17:40:07Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shubby](https://avatars.discourse-cdn.com/v4/letter/s/f9ae1b/32.png) [@Shubby](https://discourse.chef.io/u/Shubby)\
**Post date:** [February 26, 2015, 5:40pm UTC](https://discourse.chef.io/t/malformed-array-causing-chef-to-error-out/6354/1 "2015-02-26T17:40:07Z")

</div>

Hi there,  
I can’t figure out what I’m doing wrong with this. It seems trivial enough  
but I’m not a software developer and this is puzzling me right now. I think  
my issue has more to do with pure Ruby than Chef but either way, I can’t  
figure it out.  
If it matters, I’m working with chef-solo 12.0.3 and provisioning things  
via Vagrant 1.7.2.

I’m doing something that should be pretty straightforward: creating a  
number of directories declared in an array:

dirs = [Chef::Config[:data\_bag\_path],  
"#{Chef::Config[:data\_bag\_path]}/#{node[‘data\_bag’]}" ]

dirs.each do |dir|  
directory dir do  
owner "foo"  
group "foo"  
mode 00440  
recursive true  
action :create  
end  
end

This results in the following error during provisioning  
==\> default: Compiled Resource:  
==\> default: ------------------  
==\> default: # Declared in  
/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/cookbooks/nap/recipes/default.rb:90:in  
`block in from\_file’  
==\> default:  
==\> default:  
directory("["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]")  
do  
==\> default: action [:create]  
==\> default: retries 0  
==\> default: retry\_delay 2  
==\> default: default\_guard\_interpreter :default  
==\> default: path  
["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]  
==\> default: recursive true  
==\> default: declared\_type :directory  
==\> default: cookbook\_name :nap  
==\> default: recipe\_name “default”  
==\> default: owner “foo”  
==\> default: group “foo”  
==\> default: mode 288  
==\> default: end  
==\> default:  
==\> default: [2015-02-26T12:09:20-05:00] INFO: Running queued delayed  
notifications before re-raising exception  
==\> default: [2015-02-26T12:09:20-05:00] ERROR: Running exception handlers  
==\> default: [2015-02-26T12:09:20-05:00] ERROR: Exception handlers complete  
==\> default: [2015-02-26T12:09:20-05:00] FATAL: Stacktrace dumped to  
/var/chef/cache/chef-stacktrace.out  
==\> default: [2015-02-26T12:09:20-05:00] ERROR:  
directory[["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]]  
(nap::default line 90) had an error: Chef::Exceptions::ValidationFailed:  
Option path must be a kind of String! You passed  
["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"].  
==\> default: [2015-02-26T12:09:21-05:00] FATAL:  
Chef::Exceptions::ChildConvergeError: Chef run process exited  
unsuccessfully (exit code 1)

I ran this through chef-shell as well:  
$ chef-shell -s -c solo.rb  
loading configuration: solo.rb  
Session type: solo  
Loading…done.  
Ohai2u vagrant@nap-cookbook!  
chef \> puts Chef::Config[:data\_bag\_path]  
/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags  
=\> nil  
chef \> dirs = [Chef::Config[:data\_bag\_path],  
"#{Chef::Config[:data\_bag\_path]}/#{node[‘foo’][‘bar’]}" ]  
NoMethodError: undefined method `[]' for nil:NilClass from (irb):3 from /opt/chef/embedded/apps/chef/lib/chef/shell.rb:75:in`block in  
start’  
from /opt/chef/embedded/apps/chef/lib/chef/shell.rb:74:in `catch' from /opt/chef/embedded/apps/chef/lib/chef/shell.rb:74:in`start’  
from /opt/chef/embedded/apps/chef/bin/chef-shell:37:in `<top (required)>' from /usr/bin/chef-shell:40:in`load’  
from /usr/bin/chef-shell:40:in `'  
chef \> dirs = []  
=\> []  
chef \> dirs = [Chef::Config[:data\_bag\_path] ]  
=\> [["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]]  
chef \> puts dirs  
/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags  
=\> nil  
chef \> dirs = [Chef::Config[:data\_bag\_path],  
"#{Chef::Config[:data\_bag\_path]}/test" ]  
=\> [["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"],  
"["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]/test"]  
chef \> puts dirs  
/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags  
["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]/test  
=\> nil  
chef \>

So as you can see in the above output, it’s adding brackets around some of  
the things stored in the array and that seems to be why the Chef run is  
failing, but I don’t understand why adding the brackets to begin with.

I also have no idea why this line produces an error:  
chef \> dirs = [Chef::Config[:data\_bag\_path],  
"#{Chef::Config[:data\_bag\_path]}/#{node[‘foo’][‘bar’]}" ]

Would somebody please mind explaining what I’m doing wrong? Thank you!

---

<div class="post-metadata">

**Author:** ![Brandon\_Raabe](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/brandon_raabe/32/40_2.png) [@Brandon\_Raabe](https://discourse.chef.io/u/Brandon_Raabe)\
**Post date:** [February 26, 2015, 6:03pm UTC](https://discourse.chef.io/t/malformed-array-causing-chef-to-error-out/6354/2 "2015-02-26T18:03:59Z")

</div>

It looks like your first entry is an array.

dirs = [_Chef::Config[:data\_bag\_path]_,  
"#{Chef::Config[:data\_bag\_path]}/#{node['data\_bag']}"  
]

directory("\*["/tmp/vagrant-\*_chef/c0f72feb81f20d85ca657a73371fce_  
_cb/data\_bags"]_") do

You can force it to create the entire path by adding the recursive  
attribute to you directory resource.

On Thu, Feb 26, 2015 at 10:40 AM, Fabien Delpierre \<  
[fabien.delpierre@gmail.com](mailto:fabien.delpierre@gmail.com)\> wrote:

> Hi there,  
> I can't figure out what I'm doing wrong with this. It seems trivial enough  
> but I'm not a software developer and this is puzzling me right now. I think  
> my issue has more to do with pure Ruby than Chef but either way, I can't  
> figure it out.  
> If it matters, I'm working with chef-solo 12.0.3 and provisioning things  
> via Vagrant 1.7.2.
> 
> I'm doing something that should be pretty straightforward: creating a  
> number of directories declared in an array:
> 
> dirs = [Chef::Config[:data\_bag\_path],  
> "#{Chef::Config[:data\_bag\_path]}/#{node['data\_bag']}" ]
> 
> dirs.each do |dir|  
> directory dir do  
> owner "foo"  
> group "foo"  
> mode 00440  
> recursive true  
> action :create  
> end  
> end
> 
> This results in the following error during provisioning  
> ==\> default: Compiled Resource:  
> ==\> default: ------------------  
> ==\> default: # Declared in  
> /tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/cookbooks/nap/recipes/default.rb:90:in  
> `block in from\_file'  
> ==\> default:  
> ==\> default:  
> directory("["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]")  
> do  
> ==\> default: action [:create]  
> ==\> default: retries 0  
> ==\> default: retry\_delay 2  
> ==\> default: default\_guard\_interpreter :default  
> ==\> default: path  
> ["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]  
> ==\> default: recursive true  
> ==\> default: declared\_type :directory  
> ==\> default: cookbook\_name :nap  
> ==\> default: recipe\_name "default"  
> ==\> default: owner "foo"  
> ==\> default: group "foo"  
> ==\> default: mode 288  
> ==\> default: end  
> ==\> default:  
> ==\> default: [2015-02-26T12:09:20-05:00] INFO: Running queued delayed  
> notifications before re-raising exception  
> ==\> default: [2015-02-26T12:09:20-05:00] ERROR: Running exception handlers  
> ==\> default: [2015-02-26T12:09:20-05:00] ERROR: Exception handlers complete  
> ==\> default: [2015-02-26T12:09:20-05:00] FATAL: Stacktrace dumped to  
> /var/chef/cache/chef-stacktrace.out  
> ==\> default: [2015-02-26T12:09:20-05:00] ERROR:  
> directory[["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]]  
> (nap::default line 90) had an error: Chef::Exceptions::ValidationFailed:  
> Option path must be a kind of String! You passed  
> ["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"].  
> ==\> default: [2015-02-26T12:09:21-05:00] FATAL:  
> Chef::Exceptions::ChildConvergeError: Chef run process exited  
> unsuccessfully (exit code 1)
> 
> I ran this through chef-shell as well:  
> $ chef-shell -s -c solo.rb  
> loading configuration: solo.rb  
> Session type: solo  
> Loading.............done.  
> Ohai2u vagrant@nap-cookbook!  
> chef \> puts Chef::Config[:data\_bag\_path]  
> /tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags  
> =\> nil  
> chef \> dirs = [Chef::Config[:data\_bag\_path],  
> "#{Chef::Config[:data\_bag\_path]}/#{node['foo']['bar']}" ]  
> NoMethodError: undefined method `[]' for nil:NilClass from (irb):3 from /opt/chef/embedded/apps/chef/lib/chef/shell.rb:75:in `block in  
> start'  
> from /opt/chef/embedded/apps/chef/lib/chef/shell.rb:74:in `catch' from /opt/chef/embedded/apps/chef/lib/chef/shell.rb:74:in `start'  
> from /opt/chef/embedded/apps/chef/bin/chef-shell:37:in `<top (required)>' from /usr/bin/chef-shell:40:in `load'  
> from /usr/bin/chef-shell:40:in `'  
> chef \> dirs =   
> =\>   
> chef \> dirs = [Chef::Config[:data\_bag\_path] ]  
> =\> [["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]]  
> chef \> puts dirs  
> /tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags  
> =\> nil  
> chef \> dirs = [Chef::Config[:data\_bag\_path],  
> "#{Chef::Config[:data\_bag\_path]}/test" ]  
> =\> [["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"],  
> "["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]/test"]  
> chef \> puts dirs  
> /tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags  
> ["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]/test  
> =\> nil  
> chef \>
> 
> So as you can see in the above output, it's adding brackets around some of  
> the things stored in the array and that seems to be why the Chef run is  
> failing, but I don't understand why adding the brackets to begin with.
> 
> I also have no idea why this line produces an error:  
> chef \> dirs = [Chef::Config[:data\_bag\_path],  
> "#{Chef::Config[:data\_bag\_path]}/#{node['foo']['bar']}" ]
> 
> Would somebody please mind explaining what I'm doing wrong? Thank you!

---

<div class="post-metadata">

**Author:** ![Shubby](https://avatars.discourse-cdn.com/v4/letter/s/f9ae1b/32.png) [@Shubby](https://discourse.chef.io/u/Shubby)\
**Post date:** [February 26, 2015, 6:19pm UTC](https://discourse.chef.io/t/malformed-array-causing-chef-to-error-out/6354/3 "2015-02-26T18:19:22Z")

</div>

Thanks.  
Why is Chef::Config[:data\_bag\_path] an array, though?  
Also, you may have noticed I already have the recursive attribute set to  
true, but per the docs, it doesn't apply recursive permissions, and I want  
to set the right permissions on both folders.

Anyway, I commented out the code I posted earlier and used this instead:

directory "#{Chef::Config[:data\_bag\_path]}/#{node['nap']['data\_bag']}" do  
owner node['nap']['provisioning\_owner']  
group node['nap']['provisioning\_group']  
mode 00440  
recursive true  
action :create  
end

The Chef run ran successfully. The run output says:  
==\> default: [2015-02-26T13:12:59-05:00] INFO:  
directory[["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]/nap-vagrant]  
created directory  
["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]/nap-vagrant  
==\> default: [2015-02-26T13:12:59-05:00] INFO:  
directory[["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]/nap-vagrant]  
owner changed to 500  
==\> default: [2015-02-26T13:12:59-05:00] INFO:  
directory[["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]/nap-vagrant]  
group changed to 0  
==\> default: [2015-02-26T13:12:59-05:00] INFO:  
directory[["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]/nap-vagrant]  
mode changed to 440

You can see the brackets are still there and it looks fishy. Sure enough,  
/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags does not  
exist. However I now have a folder directly under / called '["' with the  
above directory structure underneath it, i.e.  
/["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]

So I'm still in trouble 🙂

On Thu, Feb 26, 2015 at 1:03 PM, Brandon Raabe [brandocorp@gmail.com](mailto:brandocorp@gmail.com) wrote:

> It looks like your first entry is an array.
> 
> dirs = [_Chef::Config[:data\_bag\_path]_, "#{Chef::Config[:data\_bag\_path]}/#{node['data\_bag']}"  
> ]
> 
> directory("\*["/tmp/vagrant-\*_chef/c0f72feb81f20d85ca657a73371fce_  
> _cb/data\_bags"]_") do
> 
> You can force it to create the entire path by adding the recursive  
> attribute to you directory resource.
> 
> On Thu, Feb 26, 2015 at 10:40 AM, Fabien Delpierre \<  
> [fabien.delpierre@gmail.com](mailto:fabien.delpierre@gmail.com)\> wrote:
> 
> > Hi there,  
> > I can't figure out what I'm doing wrong with this. It seems trivial  
> > enough but I'm not a software developer and this is puzzling me right now.  
> > I think my issue has more to do with pure Ruby than Chef but either way, I  
> > can't figure it out.  
> > If it matters, I'm working with chef-solo 12.0.3 and provisioning things  
> > via Vagrant 1.7.2.
> > 
> > I'm doing something that should be pretty straightforward: creating a  
> > number of directories declared in an array:
> > 
> > dirs = [Chef::Config[:data\_bag\_path],  
> > "#{Chef::Config[:data\_bag\_path]}/#{node['data\_bag']}" ]
> > 
> > dirs.each do |dir|  
> > directory dir do  
> > owner "foo"  
> > group "foo"  
> > mode 00440  
> > recursive true  
> > action :create  
> > end  
> > end
> > 
> > This results in the following error during provisioning  
> > ==\> default: Compiled Resource:  
> > ==\> default: ------------------  
> > ==\> default: # Declared in  
> > /tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/cookbooks/nap/recipes/default.rb:90:in  
> > `block in from\_file'  
> > ==\> default:  
> > ==\> default:  
> > directory("["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]")  
> > do  
> > ==\> default: action [:create]  
> > ==\> default: retries 0  
> > ==\> default: retry\_delay 2  
> > ==\> default: default\_guard\_interpreter :default  
> > ==\> default: path  
> > ["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]  
> > ==\> default: recursive true  
> > ==\> default: declared\_type :directory  
> > ==\> default: cookbook\_name :nap  
> > ==\> default: recipe\_name "default"  
> > ==\> default: owner "foo"  
> > ==\> default: group "foo"  
> > ==\> default: mode 288  
> > ==\> default: end  
> > ==\> default:  
> > ==\> default: [2015-02-26T12:09:20-05:00] INFO: Running queued delayed  
> > notifications before re-raising exception  
> > ==\> default: [2015-02-26T12:09:20-05:00] ERROR: Running exception handlers  
> > ==\> default: [2015-02-26T12:09:20-05:00] ERROR: Exception handlers  
> > complete  
> > ==\> default: [2015-02-26T12:09:20-05:00] FATAL: Stacktrace dumped to  
> > /var/chef/cache/chef-stacktrace.out  
> > ==\> default: [2015-02-26T12:09:20-05:00] ERROR:  
> > directory[["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]]  
> > (nap::default line 90) had an error: Chef::Exceptions::ValidationFailed:  
> > Option path must be a kind of String! You passed  
> > ["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"].  
> > ==\> default: [2015-02-26T12:09:21-05:00] FATAL:  
> > Chef::Exceptions::ChildConvergeError: Chef run process exited  
> > unsuccessfully (exit code 1)
> > 
> > I ran this through chef-shell as well:  
> > $ chef-shell -s -c solo.rb  
> > loading configuration: solo.rb  
> > Session type: solo  
> > Loading.............done.  
> > Ohai2u vagrant@nap-cookbook!  
> > chef \> puts Chef::Config[:data\_bag\_path]  
> > /tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags  
> > =\> nil  
> > chef \> dirs = [Chef::Config[:data\_bag\_path],  
> > "#{Chef::Config[:data\_bag\_path]}/#{node['foo']['bar']}" ]  
> > NoMethodError: undefined method `[]' for nil:NilClass from (irb):3 from /opt/chef/embedded/apps/chef/lib/chef/shell.rb:75:in `block in  
> > start'  
> > from /opt/chef/embedded/apps/chef/lib/chef/shell.rb:74:in `catch' from /opt/chef/embedded/apps/chef/lib/chef/shell.rb:74:in `start'  
> > from /opt/chef/embedded/apps/chef/bin/chef-shell:37:in `<top (required)>' from /usr/bin/chef-shell:40:in `load'  
> > from /usr/bin/chef-shell:40:in `'  
> > chef \> dirs =   
> > =\>   
> > chef \> dirs = [Chef::Config[:data\_bag\_path] ]  
> > =\> [["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]]  
> > chef \> puts dirs  
> > /tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags  
> > =\> nil  
> > chef \> dirs = [Chef::Config[:data\_bag\_path],  
> > "#{Chef::Config[:data\_bag\_path]}/test" ]  
> > =\> [["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"],  
> > "["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]/test"]  
> > chef \> puts dirs  
> > /tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags  
> > ["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]/test  
> > =\> nil  
> > chef \>
> > 
> > So as you can see in the above output, it's adding brackets around some  
> > of the things stored in the array and that seems to be why the Chef run is  
> > failing, but I don't understand why adding the brackets to begin with.
> > 
> > I also have no idea why this line produces an error:  
> > chef \> dirs = [Chef::Config[:data\_bag\_path],  
> > "#{Chef::Config[:data\_bag\_path]}/#{node['foo']['bar']}" ]
> > 
> > Would somebody please mind explaining what I'm doing wrong? Thank you!

---

<div class="post-metadata">

**Author:** ![Brandon\_Raabe](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/brandon_raabe/32/40_2.png) [@Brandon\_Raabe](https://discourse.chef.io/u/Brandon_Raabe)\
**Post date:** [February 26, 2015, 6:20pm UTC](https://discourse.chef.io/t/malformed-array-causing-chef-to-error-out/6354/4 "2015-02-26T18:20:08Z")

</div>

That was less than helpful, let me try again...

When you're creating your array of directories, the first entry is, itself,  
an array. The second entry is based on the first, and since it is an array  
being interpolated into a string, you end up with another funky entry in  
your dirs array.

You can see this in irb:

irb(main):001:0\> data\_bags\_path = ["/var/chef/cach/data\_bags"]  
=\> ["/var/chef/cach/data\_bags"]  
irb(main):002:0\> dirs = [data\_bags\_path, "#{data\_bags\_path}/my\_data\_bag"]  
=\> [["/var/chef/cach/data\_bags"],  
"["/var/chef/cach/data\_bags"]/my\_data\_bag"]

Assuming you're not adding any additional custom paths to the data bags  
path, you can fix this by taking the first entry from the array and using  
that in your dirs variable like this:

data\_bags\_path = Chef::Config[:data\_bag\_path].first  
dirs = [data\_bags\_path, "#{data\_bags\_path}/#{node['data\_bag']}" ]

Alternatively, you can use the recursive attribute of the directory  
resource, and skip creating the data\_bags\_path directory, because it would  
be recursively created by the resource.

data\_bags\_path = Chef::Config[:data\_bag\_path].first  
dirs = ["#{data\_bags\_path}/#{node['data\_bag']}" ]

dirs.each do |dir|  
directory dir do  
recursive true  
end  
end

On Thu, Feb 26, 2015 at 11:03 AM, Brandon Raabe [brandocorp@gmail.com](mailto:brandocorp@gmail.com)  
wrote:

> It looks like your first entry is an array.
> 
> dirs = [_Chef::Config[:data\_bag\_path]_, "#{Chef::Config[:data\_bag\_path]}/#{node['data\_bag']}"  
> ]
> 
> directory("\*["/tmp/vagrant-\*_chef/c0f72feb81f20d85ca657a73371fce_  
> _cb/data\_bags"]_") do
> 
> You can force it to create the entire path by adding the recursive  
> attribute to you directory resource.
> 
> On Thu, Feb 26, 2015 at 10:40 AM, Fabien Delpierre \<  
> [fabien.delpierre@gmail.com](mailto:fabien.delpierre@gmail.com)\> wrote:
> 
> > Hi there,  
> > I can't figure out what I'm doing wrong with this. It seems trivial  
> > enough but I'm not a software developer and this is puzzling me right now.  
> > I think my issue has more to do with pure Ruby than Chef but either way, I  
> > can't figure it out.  
> > If it matters, I'm working with chef-solo 12.0.3 and provisioning things  
> > via Vagrant 1.7.2.
> > 
> > I'm doing something that should be pretty straightforward: creating a  
> > number of directories declared in an array:
> > 
> > dirs = [Chef::Config[:data\_bag\_path],  
> > "#{Chef::Config[:data\_bag\_path]}/#{node['data\_bag']}" ]
> > 
> > dirs.each do |dir|  
> > directory dir do  
> > owner "foo"  
> > group "foo"  
> > mode 00440  
> > recursive true  
> > action :create  
> > end  
> > end
> > 
> > This results in the following error during provisioning  
> > ==\> default: Compiled Resource:  
> > ==\> default: ------------------  
> > ==\> default: # Declared in  
> > /tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/cookbooks/nap/recipes/default.rb:90:in  
> > `block in from\_file'  
> > ==\> default:  
> > ==\> default:  
> > directory("["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]")  
> > do  
> > ==\> default: action [:create]  
> > ==\> default: retries 0  
> > ==\> default: retry\_delay 2  
> > ==\> default: default\_guard\_interpreter :default  
> > ==\> default: path  
> > ["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]  
> > ==\> default: recursive true  
> > ==\> default: declared\_type :directory  
> > ==\> default: cookbook\_name :nap  
> > ==\> default: recipe\_name "default"  
> > ==\> default: owner "foo"  
> > ==\> default: group "foo"  
> > ==\> default: mode 288  
> > ==\> default: end  
> > ==\> default:  
> > ==\> default: [2015-02-26T12:09:20-05:00] INFO: Running queued delayed  
> > notifications before re-raising exception  
> > ==\> default: [2015-02-26T12:09:20-05:00] ERROR: Running exception handlers  
> > ==\> default: [2015-02-26T12:09:20-05:00] ERROR: Exception handlers  
> > complete  
> > ==\> default: [2015-02-26T12:09:20-05:00] FATAL: Stacktrace dumped to  
> > /var/chef/cache/chef-stacktrace.out  
> > ==\> default: [2015-02-26T12:09:20-05:00] ERROR:  
> > directory[["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]]  
> > (nap::default line 90) had an error: Chef::Exceptions::ValidationFailed:  
> > Option path must be a kind of String! You passed  
> > ["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"].  
> > ==\> default: [2015-02-26T12:09:21-05:00] FATAL:  
> > Chef::Exceptions::ChildConvergeError: Chef run process exited  
> > unsuccessfully (exit code 1)
> > 
> > I ran this through chef-shell as well:  
> > $ chef-shell -s -c solo.rb  
> > loading configuration: solo.rb  
> > Session type: solo  
> > Loading.............done.  
> > Ohai2u vagrant@nap-cookbook!  
> > chef \> puts Chef::Config[:data\_bag\_path]  
> > /tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags  
> > =\> nil  
> > chef \> dirs = [Chef::Config[:data\_bag\_path],  
> > "#{Chef::Config[:data\_bag\_path]}/#{node['foo']['bar']}" ]  
> > NoMethodError: undefined method `[]' for nil:NilClass from (irb):3 from /opt/chef/embedded/apps/chef/lib/chef/shell.rb:75:in `block in  
> > start'  
> > from /opt/chef/embedded/apps/chef/lib/chef/shell.rb:74:in `catch' from /opt/chef/embedded/apps/chef/lib/chef/shell.rb:74:in `start'  
> > from /opt/chef/embedded/apps/chef/bin/chef-shell:37:in `<top (required)>' from /usr/bin/chef-shell:40:in `load'  
> > from /usr/bin/chef-shell:40:in `'  
> > chef \> dirs =   
> > =\>   
> > chef \> dirs = [Chef::Config[:data\_bag\_path] ]  
> > =\> [["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]]  
> > chef \> puts dirs  
> > /tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags  
> > =\> nil  
> > chef \> dirs = [Chef::Config[:data\_bag\_path],  
> > "#{Chef::Config[:data\_bag\_path]}/test" ]  
> > =\> [["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"],  
> > "["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]/test"]  
> > chef \> puts dirs  
> > /tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags  
> > ["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]/test  
> > =\> nil  
> > chef \>
> > 
> > So as you can see in the above output, it's adding brackets around some  
> > of the things stored in the array and that seems to be why the Chef run is  
> > failing, but I don't understand why adding the brackets to begin with.
> > 
> > I also have no idea why this line produces an error:  
> > chef \> dirs = [Chef::Config[:data\_bag\_path],  
> > "#{Chef::Config[:data\_bag\_path]}/#{node['foo']['bar']}" ]
> > 
> > Would somebody please mind explaining what I'm doing wrong? Thank you!

---

<div class="post-metadata">

**Author:** ![Ranjib](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/ranjib/32/1040_2.png) [@Ranjib](https://discourse.chef.io/u/Ranjib)\
**Post date:** [February 26, 2015, 6:48pm UTC](https://discourse.chef.io/t/malformed-array-causing-chef-to-error-out/6354/5 "2015-02-26T18:48:35Z")

</div>

Why is Chef::Config[:data\_bag\_path] an array?

- because you can have multiple folder containing the data bags. this is  
similar to cookbook\_path. In your case you can just use .first.  
Recursive directory and permission:
- If any of the parent directory exist should Chef change its permission?  
Is that intended? If chef creates one of the parent directory the dafault  
permissions will govern by umask etc.. should chef change that? Current  
behavior is to leave them as it is (or let umask govern them). I find it  
safer

just curious why you are trying to create data bag paths?

On Thu, Feb 26, 2015 at 10:19 AM, Fabien Delpierre \<  
[fabien.delpierre@gmail.com](mailto:fabien.delpierre@gmail.com)\> wrote:

> Thanks.  
> Why is Chef::Config[:data\_bag\_path] an array, though?  
> Also, you may have noticed I already have the recursive attribute set to  
> true, but per the docs, it doesn't apply recursive permissions, and I want  
> to set the right permissions on both folders.
> 
> Anyway, I commented out the code I posted earlier and used this instead:
> 
> directory "#{Chef::Config[:data\_bag\_path]}/#{node['nap']['data\_bag']}" do  
> owner node['nap']['provisioning\_owner']  
> group node['nap']['provisioning\_group']  
> mode 00440  
> recursive true  
> action :create  
> end
> 
> The Chef run ran successfully. The run output says:  
> ==\> default: [2015-02-26T13:12:59-05:00] INFO:  
> directory[["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]/nap-vagrant]  
> created directory  
> ["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]/nap-vagrant  
> ==\> default: [2015-02-26T13:12:59-05:00] INFO:  
> directory[["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]/nap-vagrant]  
> owner changed to 500  
> ==\> default: [2015-02-26T13:12:59-05:00] INFO:  
> directory[["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]/nap-vagrant]  
> group changed to 0  
> ==\> default: [2015-02-26T13:12:59-05:00] INFO:  
> directory[["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]/nap-vagrant]  
> mode changed to 440
> 
> You can see the brackets are still there and it looks fishy. Sure enough,  
> /tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags does not  
> exist. However I now have a folder directly under / called '["' with the  
> above directory structure underneath it, i.e.  
> /["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]
> 
> So I'm still in trouble 🙂
> 
> On Thu, Feb 26, 2015 at 1:03 PM, Brandon Raabe [brandocorp@gmail.com](mailto:brandocorp@gmail.com)  
> wrote:
> 
> > It looks like your first entry is an array.
> > 
> > dirs = [_Chef::Config[:data\_bag\_path]_, "#{Chef::Config[:data\_bag\_path]}/#{node['data\_bag']}"  
> > ]
> > 
> > directory("\*["/tmp/vagrant-\*_chef/c0f72feb81f20d85ca657a73371fce_  
> > _cb/data\_bags"]_") do
> > 
> > You can force it to create the entire path by adding the recursive  
> > attribute to you directory resource.
> > 
> > On Thu, Feb 26, 2015 at 10:40 AM, Fabien Delpierre \<  
> > [fabien.delpierre@gmail.com](mailto:fabien.delpierre@gmail.com)\> wrote:
> > 
> > > Hi there,  
> > > I can't figure out what I'm doing wrong with this. It seems trivial  
> > > enough but I'm not a software developer and this is puzzling me right now.  
> > > I think my issue has more to do with pure Ruby than Chef but either way, I  
> > > can't figure it out.  
> > > If it matters, I'm working with chef-solo 12.0.3 and provisioning things  
> > > via Vagrant 1.7.2.
> > > 
> > > I'm doing something that should be pretty straightforward: creating a  
> > > number of directories declared in an array:
> > > 
> > > dirs = [Chef::Config[:data\_bag\_path],  
> > > "#{Chef::Config[:data\_bag\_path]}/#{node['data\_bag']}" ]
> > > 
> > > dirs.each do |dir|  
> > > directory dir do  
> > > owner "foo"  
> > > group "foo"  
> > > mode 00440  
> > > recursive true  
> > > action :create  
> > > end  
> > > end
> > > 
> > > This results in the following error during provisioning  
> > > ==\> default: Compiled Resource:  
> > > ==\> default: ------------------  
> > > ==\> default: # Declared in  
> > > /tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/cookbooks/nap/recipes/default.rb:90:in  
> > > `block in from\_file'  
> > > ==\> default:  
> > > ==\> default:  
> > > directory("["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]")  
> > > do  
> > > ==\> default: action [:create]  
> > > ==\> default: retries 0  
> > > ==\> default: retry\_delay 2  
> > > ==\> default: default\_guard\_interpreter :default  
> > > ==\> default: path  
> > > ["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]  
> > > ==\> default: recursive true  
> > > ==\> default: declared\_type :directory  
> > > ==\> default: cookbook\_name :nap  
> > > ==\> default: recipe\_name "default"  
> > > ==\> default: owner "foo"  
> > > ==\> default: group "foo"  
> > > ==\> default: mode 288  
> > > ==\> default: end  
> > > ==\> default:  
> > > ==\> default: [2015-02-26T12:09:20-05:00] INFO: Running queued delayed  
> > > notifications before re-raising exception  
> > > ==\> default: [2015-02-26T12:09:20-05:00] ERROR: Running exception  
> > > handlers  
> > > ==\> default: [2015-02-26T12:09:20-05:00] ERROR: Exception handlers  
> > > complete  
> > > ==\> default: [2015-02-26T12:09:20-05:00] FATAL: Stacktrace dumped to  
> > > /var/chef/cache/chef-stacktrace.out  
> > > ==\> default: [2015-02-26T12:09:20-05:00] ERROR:  
> > > directory[["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]]  
> > > (nap::default line 90) had an error: Chef::Exceptions::ValidationFailed:  
> > > Option path must be a kind of String! You passed  
> > > ["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"].  
> > > ==\> default: [2015-02-26T12:09:21-05:00] FATAL:  
> > > Chef::Exceptions::ChildConvergeError: Chef run process exited  
> > > unsuccessfully (exit code 1)
> > > 
> > > I ran this through chef-shell as well:  
> > > $ chef-shell -s -c solo.rb  
> > > loading configuration: solo.rb  
> > > Session type: solo  
> > > Loading.............done.  
> > > Ohai2u vagrant@nap-cookbook!  
> > > chef \> puts Chef::Config[:data\_bag\_path]  
> > > /tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags  
> > > =\> nil  
> > > chef \> dirs = [Chef::Config[:data\_bag\_path],  
> > > "#{Chef::Config[:data\_bag\_path]}/#{node['foo']['bar']}" ]  
> > > NoMethodError: undefined method `[]' for nil:NilClass from (irb):3 from /opt/chef/embedded/apps/chef/lib/chef/shell.rb:75:in `block in  
> > > start'  
> > > from /opt/chef/embedded/apps/chef/lib/chef/shell.rb:74:in `catch' from /opt/chef/embedded/apps/chef/lib/chef/shell.rb:74:in `start'  
> > > from /opt/chef/embedded/apps/chef/bin/chef-shell:37:in `<top (required)>' from /usr/bin/chef-shell:40:in `load'  
> > > from /usr/bin/chef-shell:40:in `'  
> > > chef \> dirs =   
> > > =\>   
> > > chef \> dirs = [Chef::Config[:data\_bag\_path] ]  
> > > =\> [["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]]  
> > > chef \> puts dirs  
> > > /tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags  
> > > =\> nil  
> > > chef \> dirs = [Chef::Config[:data\_bag\_path],  
> > > "#{Chef::Config[:data\_bag\_path]}/test" ]  
> > > =\> [["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"],  
> > > "["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]/test"]  
> > > chef \> puts dirs  
> > > /tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags  
> > > ["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]/test  
> > > =\> nil  
> > > chef \>
> > > 
> > > So as you can see in the above output, it's adding brackets around some  
> > > of the things stored in the array and that seems to be why the Chef run is  
> > > failing, but I don't understand why adding the brackets to begin with.
> > > 
> > > I also have no idea why this line produces an error:  
> > > chef \> dirs = [Chef::Config[:data\_bag\_path],  
> > > "#{Chef::Config[:data\_bag\_path]}/#{node['foo']['bar']}" ]
> > > 
> > > Would somebody please mind explaining what I'm doing wrong? Thank you!

---

<div class="post-metadata">

**Author:** ![Shubby](https://avatars.discourse-cdn.com/v4/letter/s/f9ae1b/32.png) [@Shubby](https://discourse.chef.io/u/Shubby)\
**Post date:** [February 26, 2015, 7:07pm UTC](https://discourse.chef.io/t/malformed-array-causing-chef-to-error-out/6354/6 "2015-02-26T19:07:01Z")

</div>

Ok, thanks. So, really, what I should take away from all this is that  
Chef::Config[:data\_bag\_path], for some reason, is an array and I just have  
to deal with it. That it would be an array didn't make sense to me so I  
didn't even check to see if it was an array, despite the signs.

irb(main):001:0\> test = "1"  
=\> "1"  
irb(main):002:0\> puts test  
1  
=\> nil  
irb(main):003:0\> test.push("2")  
NoMethodError: undefined method `push' for "1":String from (irb):3 from /opt/chefdk/embedded/bin/irb:11:in `'  
irb(main):004:0\> test = ["1"]  
=\> ["1"]  
irb(main):005:0\> puts test  
1  
=\> nil  
irb(main):006:0\> test.push("2")  
=\> ["1", "2"]

So I learned that if there's only one thing stored in an array, if you  
display the contents of the array, you can't tell that it is an array from  
the output, which is why I was confused to begin with:  
chef \> puts Chef::Config[:data\_bag\_path]  
/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags  
=\> nil  
Doesn't look like an array.

However:  
chef \> Chef::Config[:data\_bag\_path].kind\_of?(Array)  
=\> true

Likewise you can push additional values to it.

Alright, so lesson learned! I can work with that now. Thanks!

On Thu, Feb 26, 2015 at 1:20 PM, Brandon Raabe [brandocorp@gmail.com](mailto:brandocorp@gmail.com) wrote:

> That was less than helpful, let me try again...
> 
> When you're creating your array of directories, the first entry is,  
> itself, an array. The second entry is based on the first, and since it is  
> an array being interpolated into a string, you end up with another funky  
> entry in your dirs array.
> 
> You can see this in irb:
> 
> irb(main):001:0\> data\_bags\_path = ["/var/chef/cach/data\_bags"]  
> =\> ["/var/chef/cach/data\_bags"]  
> irb(main):002:0\> dirs = [data\_bags\_path, "#{data\_bags\_path}/my\_data\_bag"]  
> =\> [["/var/chef/cach/data\_bags"],  
> "["/var/chef/cach/data\_bags"]/my\_data\_bag"]
> 
> Assuming you're not adding any additional custom paths to the data bags  
> path, you can fix this by taking the first entry from the array and using  
> that in your dirs variable like this:
> 
> data\_bags\_path = Chef::Config[:data\_bag\_path].first  
> dirs = [data\_bags\_path, "#{data\_bags\_path}/#{node['data\_bag']}" ]
> 
> Alternatively, you can use the recursive attribute of the directory  
> resource, and skip creating the data\_bags\_path directory, because it  
> would be recursively created by the resource.
> 
> data\_bags\_path = Chef::Config[:data\_bag\_path].first  
> dirs = ["#{data\_bags\_path}/#{node['data\_bag']}" ]
> 
> dirs.each do |dir|  
> directory dir do  
> recursive true  
> end  
> end
> 
> On Thu, Feb 26, 2015 at 11:03 AM, Brandon Raabe [brandocorp@gmail.com](mailto:brandocorp@gmail.com)  
> wrote:
> 
> > It looks like your first entry is an array.
> > 
> > dirs = [_Chef::Config[:data\_bag\_path]_, "#{Chef::Config[:data\_bag\_path]}/#{node['data\_bag']}"  
> > ]
> > 
> > directory("\*["/tmp/vagrant-\*_chef/c0f72feb81f20d85ca657a73371fce_  
> > _cb/data\_bags"]_") do
> > 
> > You can force it to create the entire path by adding the recursive  
> > attribute to you directory resource.
> > 
> > On Thu, Feb 26, 2015 at 10:40 AM, Fabien Delpierre \<  
> > [fabien.delpierre@gmail.com](mailto:fabien.delpierre@gmail.com)\> wrote:
> > 
> > > Hi there,  
> > > I can't figure out what I'm doing wrong with this. It seems trivial  
> > > enough but I'm not a software developer and this is puzzling me right now.  
> > > I think my issue has more to do with pure Ruby than Chef but either way, I  
> > > can't figure it out.  
> > > If it matters, I'm working with chef-solo 12.0.3 and provisioning things  
> > > via Vagrant 1.7.2.
> > > 
> > > I'm doing something that should be pretty straightforward: creating a  
> > > number of directories declared in an array:
> > > 
> > > dirs = [Chef::Config[:data\_bag\_path],  
> > > "#{Chef::Config[:data\_bag\_path]}/#{node['data\_bag']}" ]
> > > 
> > > dirs.each do |dir|  
> > > directory dir do  
> > > owner "foo"  
> > > group "foo"  
> > > mode 00440  
> > > recursive true  
> > > action :create  
> > > end  
> > > end
> > > 
> > > This results in the following error during provisioning  
> > > ==\> default: Compiled Resource:  
> > > ==\> default: ------------------  
> > > ==\> default: # Declared in  
> > > /tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/cookbooks/nap/recipes/default.rb:90:in  
> > > `block in from\_file'  
> > > ==\> default:  
> > > ==\> default:  
> > > directory("["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]")  
> > > do  
> > > ==\> default: action [:create]  
> > > ==\> default: retries 0  
> > > ==\> default: retry\_delay 2  
> > > ==\> default: default\_guard\_interpreter :default  
> > > ==\> default: path  
> > > ["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]  
> > > ==\> default: recursive true  
> > > ==\> default: declared\_type :directory  
> > > ==\> default: cookbook\_name :nap  
> > > ==\> default: recipe\_name "default"  
> > > ==\> default: owner "foo"  
> > > ==\> default: group "foo"  
> > > ==\> default: mode 288  
> > > ==\> default: end  
> > > ==\> default:  
> > > ==\> default: [2015-02-26T12:09:20-05:00] INFO: Running queued delayed  
> > > notifications before re-raising exception  
> > > ==\> default: [2015-02-26T12:09:20-05:00] ERROR: Running exception  
> > > handlers  
> > > ==\> default: [2015-02-26T12:09:20-05:00] ERROR: Exception handlers  
> > > complete  
> > > ==\> default: [2015-02-26T12:09:20-05:00] FATAL: Stacktrace dumped to  
> > > /var/chef/cache/chef-stacktrace.out  
> > > ==\> default: [2015-02-26T12:09:20-05:00] ERROR:  
> > > directory[["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]]  
> > > (nap::default line 90) had an error: Chef::Exceptions::ValidationFailed:  
> > > Option path must be a kind of String! You passed  
> > > ["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"].  
> > > ==\> default: [2015-02-26T12:09:21-05:00] FATAL:  
> > > Chef::Exceptions::ChildConvergeError: Chef run process exited  
> > > unsuccessfully (exit code 1)
> > > 
> > > I ran this through chef-shell as well:  
> > > $ chef-shell -s -c solo.rb  
> > > loading configuration: solo.rb  
> > > Session type: solo  
> > > Loading.............done.  
> > > Ohai2u vagrant@nap-cookbook!  
> > > chef \> puts Chef::Config[:data\_bag\_path]  
> > > /tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags  
> > > =\> nil  
> > > chef \> dirs = [Chef::Config[:data\_bag\_path],  
> > > "#{Chef::Config[:data\_bag\_path]}/#{node['foo']['bar']}" ]  
> > > NoMethodError: undefined method `[]' for nil:NilClass from (irb):3 from /opt/chef/embedded/apps/chef/lib/chef/shell.rb:75:in `block in  
> > > start'  
> > > from /opt/chef/embedded/apps/chef/lib/chef/shell.rb:74:in `catch' from /opt/chef/embedded/apps/chef/lib/chef/shell.rb:74:in `start'  
> > > from /opt/chef/embedded/apps/chef/bin/chef-shell:37:in `<top (required)>' from /usr/bin/chef-shell:40:in `load'  
> > > from /usr/bin/chef-shell:40:in `'  
> > > chef \> dirs =   
> > > =\>   
> > > chef \> dirs = [Chef::Config[:data\_bag\_path] ]  
> > > =\> [["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]]  
> > > chef \> puts dirs  
> > > /tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags  
> > > =\> nil  
> > > chef \> dirs = [Chef::Config[:data\_bag\_path],  
> > > "#{Chef::Config[:data\_bag\_path]}/test" ]  
> > > =\> [["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"],  
> > > "["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]/test"]  
> > > chef \> puts dirs  
> > > /tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags  
> > > ["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]/test  
> > > =\> nil  
> > > chef \>
> > > 
> > > So as you can see in the above output, it's adding brackets around some  
> > > of the things stored in the array and that seems to be why the Chef run is  
> > > failing, but I don't understand why adding the brackets to begin with.
> > > 
> > > I also have no idea why this line produces an error:  
> > > chef \> dirs = [Chef::Config[:data\_bag\_path],  
> > > "#{Chef::Config[:data\_bag\_path]}/#{node['foo']['bar']}" ]
> > > 
> > > Would somebody please mind explaining what I'm doing wrong? Thank you!

---

<div class="post-metadata">

**Author:** ![Shubby](https://avatars.discourse-cdn.com/v4/letter/s/f9ae1b/32.png) [@Shubby](https://discourse.chef.io/u/Shubby)\
**Post date:** [February 26, 2015, 7:30pm UTC](https://discourse.chef.io/t/malformed-array-causing-chef-to-error-out/6354/7 "2015-02-26T19:30:23Z")

</div>

Ranjib,  
Perhaps I'm looking at the permissions thing the wrong way, but here's how  
I understand it: I want the files and directories I'm creating to be owned  
by the vagrant user and the root group.  
/tmp/vagrant-chef is owned by vagrant:root, however the directory  
underneath that, /tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb is  
owned by root:root. This is a folder provisioned automatically by  
Vagrant/Berkshelf, not by Chef, and I don't know if I can customize the  
ownership, or how I would do that, nor am I really concerned with that so  
long as it doesn't cause me any trouble 🙂

And to your question about why I'm creating data bag paths, well, again,  
perhaps I'm doing it wrong, but they currently don't exist, and I want them  
to exist. I'm using Chef-Solo, not Chef-Client. I'm not new to Chef-Client,  
but I've never used Chef-Solo so I'm still learning the differences.

We saw earlier that Chef::Config[:data\_bag\_path].first =  
/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags but before I  
run this code to create the directories and files I need, there is no  
data\_bags directory under  
/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb, so I need to create it  
and place a data bag item in it. The reason why I need a data bag at all is  
because I'm trying to store credentials for AWS S3 so I can then use the  
aws\_s3\_file resource from the aws cookbook  
[https://github.com/opscode-cookbooks/aws](https://github.com/opscode-cookbooks/aws). I've never had to use that  
cookbook but it says I should use a data bag to store the AWS credentials.  
I probably don't have to, but I'm going to need to use data bags to store  
some secrets for something else later. Or maybe I don't actually have to  
use data bags for this next thing I'm thinking, but I'll need to figure out  
where to put all the secrets I need to pass to the app for it to work.

On Thu, Feb 26, 2015 at 1:48 PM, Ranjib Dey [dey.ranjib@gmail.com](mailto:dey.ranjib@gmail.com) wrote:

> Why is Chef::Config[:data\_bag\_path] an array?
> 
> - because you can have multiple folder containing the data bags. this is  
> similar to cookbook\_path. In your case you can just use .first.  
> Recursive directory and permission:
> - If any of the parent directory exist should Chef change its permission?  
> Is that intended? If chef creates one of the parent directory the dafault  
> permissions will govern by umask etc.. should chef change that? Current  
> behavior is to leave them as it is (or let umask govern them). I find it  
> safer
> 
> just curious why you are trying to create data bag paths?
> 
> On Thu, Feb 26, 2015 at 10:19 AM, Fabien Delpierre \<  
> [fabien.delpierre@gmail.com](mailto:fabien.delpierre@gmail.com)\> wrote:
> 
> > Thanks.  
> > Why is Chef::Config[:data\_bag\_path] an array, though?  
> > Also, you may have noticed I already have the recursive attribute set to  
> > true, but per the docs, it doesn't apply recursive permissions, and I want  
> > to set the right permissions on both folders.
> > 
> > Anyway, I commented out the code I posted earlier and used this instead:
> > 
> > directory "#{Chef::Config[:data\_bag\_path]}/#{node['nap']['data\_bag']}" do  
> > owner node['nap']['provisioning\_owner']  
> > group node['nap']['provisioning\_group']  
> > mode 00440  
> > recursive true  
> > action :create  
> > end
> > 
> > The Chef run ran successfully. The run output says:  
> > ==\> default: [2015-02-26T13:12:59-05:00] INFO:  
> > directory[["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]/nap-vagrant]  
> > created directory  
> > ["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]/nap-vagrant  
> > ==\> default: [2015-02-26T13:12:59-05:00] INFO:  
> > directory[["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]/nap-vagrant]  
> > owner changed to 500  
> > ==\> default: [2015-02-26T13:12:59-05:00] INFO:  
> > directory[["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]/nap-vagrant]  
> > group changed to 0  
> > ==\> default: [2015-02-26T13:12:59-05:00] INFO:  
> > directory[["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]/nap-vagrant]  
> > mode changed to 440
> > 
> > You can see the brackets are still there and it looks fishy. Sure enough,  
> > /tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags does not  
> > exist. However I now have a folder directly under / called '["' with the  
> > above directory structure underneath it, i.e.  
> > /["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]
> > 
> > So I'm still in trouble 🙂
> > 
> > On Thu, Feb 26, 2015 at 1:03 PM, Brandon Raabe [brandocorp@gmail.com](mailto:brandocorp@gmail.com)  
> > wrote:
> > 
> > > It looks like your first entry is an array.
> > > 
> > > dirs = [_Chef::Config[:data\_bag\_path]_, "#{Chef::Config[:data\_bag\_path]}/#{node['data\_bag']}"  
> > > ]
> > > 
> > > directory("\*["/tmp/vagrant-\*_chef/c0f72feb81f20d85ca657a73371fce_  
> > > _cb/data\_bags"]_") do
> > > 
> > > You can force it to create the entire path by adding the recursive  
> > > attribute to you directory resource.
> > > 
> > > On Thu, Feb 26, 2015 at 10:40 AM, Fabien Delpierre \<  
> > > [fabien.delpierre@gmail.com](mailto:fabien.delpierre@gmail.com)\> wrote:
> > > 
> > > > Hi there,  
> > > > I can't figure out what I'm doing wrong with this. It seems trivial  
> > > > enough but I'm not a software developer and this is puzzling me right now.  
> > > > I think my issue has more to do with pure Ruby than Chef but either way, I  
> > > > can't figure it out.  
> > > > If it matters, I'm working with chef-solo 12.0.3 and provisioning  
> > > > things via Vagrant 1.7.2.
> > > > 
> > > > I'm doing something that should be pretty straightforward: creating a  
> > > > number of directories declared in an array:
> > > > 
> > > > dirs = [Chef::Config[:data\_bag\_path],  
> > > > "#{Chef::Config[:data\_bag\_path]}/#{node['data\_bag']}" ]
> > > > 
> > > > dirs.each do |dir|  
> > > > directory dir do  
> > > > owner "foo"  
> > > > group "foo"  
> > > > mode 00440  
> > > > recursive true  
> > > > action :create  
> > > > end  
> > > > end
> > > > 
> > > > This results in the following error during provisioning  
> > > > ==\> default: Compiled Resource:  
> > > > ==\> default: ------------------  
> > > > ==\> default: # Declared in  
> > > > /tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/cookbooks/nap/recipes/default.rb:90:in  
> > > > `block in from\_file'  
> > > > ==\> default:  
> > > > ==\> default:  
> > > > directory("["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]")  
> > > > do  
> > > > ==\> default: action [:create]  
> > > > ==\> default: retries 0  
> > > > ==\> default: retry\_delay 2  
> > > > ==\> default: default\_guard\_interpreter :default  
> > > > ==\> default: path  
> > > > ["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]  
> > > > ==\> default: recursive true  
> > > > ==\> default: declared\_type :directory  
> > > > ==\> default: cookbook\_name :nap  
> > > > ==\> default: recipe\_name "default"  
> > > > ==\> default: owner "foo"  
> > > > ==\> default: group "foo"  
> > > > ==\> default: mode 288  
> > > > ==\> default: end  
> > > > ==\> default:  
> > > > ==\> default: [2015-02-26T12:09:20-05:00] INFO: Running queued delayed  
> > > > notifications before re-raising exception  
> > > > ==\> default: [2015-02-26T12:09:20-05:00] ERROR: Running exception  
> > > > handlers  
> > > > ==\> default: [2015-02-26T12:09:20-05:00] ERROR: Exception handlers  
> > > > complete  
> > > > ==\> default: [2015-02-26T12:09:20-05:00] FATAL: Stacktrace dumped to  
> > > > /var/chef/cache/chef-stacktrace.out  
> > > > ==\> default: [2015-02-26T12:09:20-05:00] ERROR:  
> > > > directory[["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]]  
> > > > (nap::default line 90) had an error: Chef::Exceptions::ValidationFailed:  
> > > > Option path must be a kind of String! You passed  
> > > > ["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"].  
> > > > ==\> default: [2015-02-26T12:09:21-05:00] FATAL:  
> > > > Chef::Exceptions::ChildConvergeError: Chef run process exited  
> > > > unsuccessfully (exit code 1)
> > > > 
> > > > I ran this through chef-shell as well:  
> > > > $ chef-shell -s -c solo.rb  
> > > > loading configuration: solo.rb  
> > > > Session type: solo  
> > > > Loading.............done.  
> > > > Ohai2u vagrant@nap-cookbook!  
> > > > chef \> puts Chef::Config[:data\_bag\_path]  
> > > > /tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags  
> > > > =\> nil  
> > > > chef \> dirs = [Chef::Config[:data\_bag\_path],  
> > > > "#{Chef::Config[:data\_bag\_path]}/#{node['foo']['bar']}" ]  
> > > > NoMethodError: undefined method `[]' for nil:NilClass from (irb):3 from /opt/chef/embedded/apps/chef/lib/chef/shell.rb:75:in `block in  
> > > > start'  
> > > > from /opt/chef/embedded/apps/chef/lib/chef/shell.rb:74:in `catch' from /opt/chef/embedded/apps/chef/lib/chef/shell.rb:74:in `start'  
> > > > from /opt/chef/embedded/apps/chef/bin/chef-shell:37:in `<top (required)>' from /usr/bin/chef-shell:40:in `load'  
> > > > from /usr/bin/chef-shell:40:in `'  
> > > > chef \> dirs =   
> > > > =\>   
> > > > chef \> dirs = [Chef::Config[:data\_bag\_path] ]  
> > > > =\> [["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]]  
> > > > chef \> puts dirs  
> > > > /tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags  
> > > > =\> nil  
> > > > chef \> dirs = [Chef::Config[:data\_bag\_path],  
> > > > "#{Chef::Config[:data\_bag\_path]}/test" ]  
> > > > =\> [["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"],  
> > > > "["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]/test"]  
> > > > chef \> puts dirs  
> > > > /tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags  
> > > > ["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]/test  
> > > > =\> nil  
> > > > chef \>
> > > > 
> > > > So as you can see in the above output, it's adding brackets around some  
> > > > of the things stored in the array and that seems to be why the Chef run is  
> > > > failing, but I don't understand why adding the brackets to begin with.
> > > > 
> > > > I also have no idea why this line produces an error:  
> > > > chef \> dirs = [Chef::Config[:data\_bag\_path],  
> > > > "#{Chef::Config[:data\_bag\_path]}/#{node['foo']['bar']}" ]
> > > > 
> > > > Would somebody please mind explaining what I'm doing wrong? Thank you!

---

<div class="post-metadata">

**Author:** ![Ranjib](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/ranjib/32/1040_2.png) [@Ranjib](https://discourse.chef.io/u/Ranjib)\
**Post date:** [February 26, 2015, 10:36pm UTC](https://discourse.chef.io/t/malformed-array-causing-chef-to-error-out/6354/8 "2015-02-26T22:36:32Z")

</div>

you can use an execute statement with 'chown -R vagrant:root /path/to/repo'  
which will do what you want.  
you can try chef-client -z (aka localmode) as well, lot of new work are  
happening their, it has solo like semantics.

On Thu, Feb 26, 2015 at 11:30 AM, Fabien Delpierre \<  
[fabien.delpierre@gmail.com](mailto:fabien.delpierre@gmail.com)\> wrote:

> Ranjib,  
> Perhaps I'm looking at the permissions thing the wrong way, but here's how  
> I understand it: I want the files and directories I'm creating to be owned  
> by the vagrant user and the root group.  
> /tmp/vagrant-chef is owned by vagrant:root, however the directory  
> underneath that, /tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb is  
> owned by root:root. This is a folder provisioned automatically by  
> Vagrant/Berkshelf, not by Chef, and I don't know if I can customize the  
> ownership, or how I would do that, nor am I really concerned with that so  
> long as it doesn't cause me any trouble 🙂
> 
> And to your question about why I'm creating data bag paths, well, again,  
> perhaps I'm doing it wrong, but they currently don't exist, and I want them  
> to exist. I'm using Chef-Solo, not Chef-Client. I'm not new to Chef-Client,  
> but I've never used Chef-Solo so I'm still learning the differences.
> 
> We saw earlier that Chef::Config[:data\_bag\_path].first =  
> /tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags but before I  
> run this code to create the directories and files I need, there is no  
> data\_bags directory under  
> /tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb, so I need to create it  
> and place a data bag item in it. The reason why I need a data bag at all is  
> because I'm trying to store credentials for AWS S3 so I can then use the  
> aws\_s3\_file resource from the aws cookbook  
> [https://github.com/opscode-cookbooks/aws](https://github.com/opscode-cookbooks/aws). I've never had to use that  
> cookbook but it says I should use a data bag to store the AWS credentials.  
> I probably don't have to, but I'm going to need to use data bags to store  
> some secrets for something else later. Or maybe I don't actually have to  
> use data bags for this next thing I'm thinking, but I'll need to figure out  
> where to put all the secrets I need to pass to the app for it to work.
> 
> On Thu, Feb 26, 2015 at 1:48 PM, Ranjib Dey [dey.ranjib@gmail.com](mailto:dey.ranjib@gmail.com) wrote:
> 
> > Why is Chef::Config[:data\_bag\_path] an array?
> > 
> > - because you can have multiple folder containing the data bags. this is  
> > similar to cookbook\_path. In your case you can just use .first.  
> > Recursive directory and permission:
> > - If any of the parent directory exist should Chef change its permission?  
> > Is that intended? If chef creates one of the parent directory the dafault  
> > permissions will govern by umask etc.. should chef change that? Current  
> > behavior is to leave them as it is (or let umask govern them). I find it  
> > safer
> > 
> > just curious why you are trying to create data bag paths?
> > 
> > On Thu, Feb 26, 2015 at 10:19 AM, Fabien Delpierre \<  
> > [fabien.delpierre@gmail.com](mailto:fabien.delpierre@gmail.com)\> wrote:
> > 
> > > Thanks.  
> > > Why is Chef::Config[:data\_bag\_path] an array, though?  
> > > Also, you may have noticed I already have the recursive attribute set to  
> > > true, but per the docs, it doesn't apply recursive permissions, and I want  
> > > to set the right permissions on both folders.
> > > 
> > > Anyway, I commented out the code I posted earlier and used this instead:
> > > 
> > > directory "#{Chef::Config[:data\_bag\_path]}/#{node['nap']['data\_bag']}" do  
> > > owner node['nap']['provisioning\_owner']  
> > > group node['nap']['provisioning\_group']  
> > > mode 00440  
> > > recursive true  
> > > action :create  
> > > end
> > > 
> > > The Chef run ran successfully. The run output says:  
> > > ==\> default: [2015-02-26T13:12:59-05:00] INFO:  
> > > directory[["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]/nap-vagrant]  
> > > created directory  
> > > ["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]/nap-vagrant  
> > > ==\> default: [2015-02-26T13:12:59-05:00] INFO:  
> > > directory[["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]/nap-vagrant]  
> > > owner changed to 500  
> > > ==\> default: [2015-02-26T13:12:59-05:00] INFO:  
> > > directory[["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]/nap-vagrant]  
> > > group changed to 0  
> > > ==\> default: [2015-02-26T13:12:59-05:00] INFO:  
> > > directory[["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]/nap-vagrant]  
> > > mode changed to 440
> > > 
> > > You can see the brackets are still there and it looks fishy. Sure  
> > > enough, /tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags does  
> > > not exist. However I now have a folder directly under / called '["' with  
> > > the above directory structure underneath it, i.e.  
> > > /["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]
> > > 
> > > So I'm still in trouble 🙂
> > > 
> > > On Thu, Feb 26, 2015 at 1:03 PM, Brandon Raabe [brandocorp@gmail.com](mailto:brandocorp@gmail.com)  
> > > wrote:
> > > 
> > > > It looks like your first entry is an array.
> > > > 
> > > > dirs = [_Chef::Config[:data\_bag\_path]_, "#{Chef::Config[:data\_bag\_path]}/#{node['data\_bag']}"  
> > > > ]
> > > > 
> > > > directory("\*["/tmp/vagrant-\*_chef/c0f72feb81f20d85ca657a73371fce_  
> > > > _cb/data\_bags"]_") do
> > > > 
> > > > You can force it to create the entire path by adding the recursive  
> > > > attribute to you directory resource.
> > > > 
> > > > On Thu, Feb 26, 2015 at 10:40 AM, Fabien Delpierre \<  
> > > > [fabien.delpierre@gmail.com](mailto:fabien.delpierre@gmail.com)\> wrote:
> > > > 
> > > > > Hi there,  
> > > > > I can't figure out what I'm doing wrong with this. It seems trivial  
> > > > > enough but I'm not a software developer and this is puzzling me right now.  
> > > > > I think my issue has more to do with pure Ruby than Chef but either way, I  
> > > > > can't figure it out.  
> > > > > If it matters, I'm working with chef-solo 12.0.3 and provisioning  
> > > > > things via Vagrant 1.7.2.
> > > > > 
> > > > > I'm doing something that should be pretty straightforward: creating a  
> > > > > number of directories declared in an array:
> > > > > 
> > > > > dirs = [Chef::Config[:data\_bag\_path],  
> > > > > "#{Chef::Config[:data\_bag\_path]}/#{node['data\_bag']}" ]
> > > > > 
> > > > > dirs.each do |dir|  
> > > > > directory dir do  
> > > > > owner "foo"  
> > > > > group "foo"  
> > > > > mode 00440  
> > > > > recursive true  
> > > > > action :create  
> > > > > end  
> > > > > end
> > > > > 
> > > > > This results in the following error during provisioning  
> > > > > ==\> default: Compiled Resource:  
> > > > > ==\> default: ------------------  
> > > > > ==\> default: # Declared in  
> > > > > /tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/cookbooks/nap/recipes/default.rb:90:in  
> > > > > `block in from\_file'  
> > > > > ==\> default:  
> > > > > ==\> default:  
> > > > > directory("["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]")  
> > > > > do  
> > > > > ==\> default: action [:create]  
> > > > > ==\> default: retries 0  
> > > > > ==\> default: retry\_delay 2  
> > > > > ==\> default: default\_guard\_interpreter :default  
> > > > > ==\> default: path  
> > > > > ["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]  
> > > > > ==\> default: recursive true  
> > > > > ==\> default: declared\_type :directory  
> > > > > ==\> default: cookbook\_name :nap  
> > > > > ==\> default: recipe\_name "default"  
> > > > > ==\> default: owner "foo"  
> > > > > ==\> default: group "foo"  
> > > > > ==\> default: mode 288  
> > > > > ==\> default: end  
> > > > > ==\> default:  
> > > > > ==\> default: [2015-02-26T12:09:20-05:00] INFO: Running queued delayed  
> > > > > notifications before re-raising exception  
> > > > > ==\> default: [2015-02-26T12:09:20-05:00] ERROR: Running exception  
> > > > > handlers  
> > > > > ==\> default: [2015-02-26T12:09:20-05:00] ERROR: Exception handlers  
> > > > > complete  
> > > > > ==\> default: [2015-02-26T12:09:20-05:00] FATAL: Stacktrace dumped to  
> > > > > /var/chef/cache/chef-stacktrace.out  
> > > > > ==\> default: [2015-02-26T12:09:20-05:00] ERROR:  
> > > > > directory[["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]]  
> > > > > (nap::default line 90) had an error: Chef::Exceptions::ValidationFailed:  
> > > > > Option path must be a kind of String! You passed  
> > > > > ["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"].  
> > > > > ==\> default: [2015-02-26T12:09:21-05:00] FATAL:  
> > > > > Chef::Exceptions::ChildConvergeError: Chef run process exited  
> > > > > unsuccessfully (exit code 1)
> > > > > 
> > > > > I ran this through chef-shell as well:  
> > > > > $ chef-shell -s -c solo.rb  
> > > > > loading configuration: solo.rb  
> > > > > Session type: solo  
> > > > > Loading.............done.  
> > > > > Ohai2u vagrant@nap-cookbook!  
> > > > > chef \> puts Chef::Config[:data\_bag\_path]  
> > > > > /tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags  
> > > > > =\> nil  
> > > > > chef \> dirs = [Chef::Config[:data\_bag\_path],  
> > > > > "#{Chef::Config[:data\_bag\_path]}/#{node['foo']['bar']}" ]  
> > > > > NoMethodError: undefined method `[]' for nil:NilClass from (irb):3 from /opt/chef/embedded/apps/chef/lib/chef/shell.rb:75:in `block  
> > > > > in start'  
> > > > > from /opt/chef/embedded/apps/chef/lib/chef/shell.rb:74:in `catch' from /opt/chef/embedded/apps/chef/lib/chef/shell.rb:74:in `start'  
> > > > > from /opt/chef/embedded/apps/chef/bin/chef-shell:37:in `<top (required)>' from /usr/bin/chef-shell:40:in `load'  
> > > > > from /usr/bin/chef-shell:40:in `'  
> > > > > chef \> dirs =   
> > > > > =\>   
> > > > > chef \> dirs = [Chef::Config[:data\_bag\_path] ]  
> > > > > =\> [["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]]  
> > > > > chef \> puts dirs  
> > > > > /tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags  
> > > > > =\> nil  
> > > > > chef \> dirs = [Chef::Config[:data\_bag\_path],  
> > > > > "#{Chef::Config[:data\_bag\_path]}/test" ]  
> > > > > =\> [["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"],  
> > > > > "["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]/test"]  
> > > > > chef \> puts dirs  
> > > > > /tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags  
> > > > > ["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]/test  
> > > > > =\> nil  
> > > > > chef \>
> > > > > 
> > > > > So as you can see in the above output, it's adding brackets around  
> > > > > some of the things stored in the array and that seems to be why the Chef  
> > > > > run is failing, but I don't understand why adding the brackets to begin  
> > > > > with.
> > > > > 
> > > > > I also have no idea why this line produces an error:  
> > > > > chef \> dirs = [Chef::Config[:data\_bag\_path],  
> > > > > "#{Chef::Config[:data\_bag\_path]}/#{node['foo']['bar']}" ]
> > > > > 
> > > > > Would somebody please mind explaining what I'm doing wrong? Thank you!

---

<div class="post-metadata">

**Author:** ![Shubby](https://avatars.discourse-cdn.com/v4/letter/s/f9ae1b/32.png) [@Shubby](https://discourse.chef.io/u/Shubby)\
**Post date:** [February 26, 2015, 11:59pm UTC](https://discourse.chef.io/t/malformed-array-causing-chef-to-error-out/6354/9 "2015-02-26T23:59:06Z")

</div>

I prefer to use the execute resource as a last resort, I don't see what  
advantage it would give me over using the directory, file or template  
resources with owner and group attributes?

On Thu, Feb 26, 2015 at 5:36 PM, Ranjib Dey [dey.ranjib@gmail.com](mailto:dey.ranjib@gmail.com) wrote:

> you can use an execute statement with 'chown -R vagrant:root  
> /path/to/repo' which will do what you want.  
> you can try chef-client -z (aka localmode) as well, lot of new work are  
> happening their, it has solo like semantics.
> 
> On Thu, Feb 26, 2015 at 11:30 AM, Fabien Delpierre \<  
> [fabien.delpierre@gmail.com](mailto:fabien.delpierre@gmail.com)\> wrote:
> 
> > Ranjib,  
> > Perhaps I'm looking at the permissions thing the wrong way, but here's  
> > how I understand it: I want the files and directories I'm creating to be  
> > owned by the vagrant user and the root group.  
> > /tmp/vagrant-chef is owned by vagrant:root, however the directory  
> > underneath that, /tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb is  
> > owned by root:root. This is a folder provisioned automatically by  
> > Vagrant/Berkshelf, not by Chef, and I don't know if I can customize the  
> > ownership, or how I would do that, nor am I really concerned with that so  
> > long as it doesn't cause me any trouble 🙂
> > 
> > And to your question about why I'm creating data bag paths, well, again,  
> > perhaps I'm doing it wrong, but they currently don't exist, and I want them  
> > to exist. I'm using Chef-Solo, not Chef-Client. I'm not new to Chef-Client,  
> > but I've never used Chef-Solo so I'm still learning the differences.
> > 
> > We saw earlier that Chef::Config[:data\_bag\_path].first =  
> > /tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags but before I  
> > run this code to create the directories and files I need, there is no  
> > data\_bags directory under  
> > /tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb, so I need to create it  
> > and place a data bag item in it. The reason why I need a data bag at all is  
> > because I'm trying to store credentials for AWS S3 so I can then use the  
> > aws\_s3\_file resource from the aws cookbook  
> > [https://github.com/opscode-cookbooks/aws](https://github.com/opscode-cookbooks/aws). I've never had to use that  
> > cookbook but it says I should use a data bag to store the AWS credentials.  
> > I probably don't have to, but I'm going to need to use data bags to store  
> > some secrets for something else later. Or maybe I don't actually have to  
> > use data bags for this next thing I'm thinking, but I'll need to figure out  
> > where to put all the secrets I need to pass to the app for it to work.
> > 
> > On Thu, Feb 26, 2015 at 1:48 PM, Ranjib Dey [dey.ranjib@gmail.com](mailto:dey.ranjib@gmail.com) wrote:
> > 
> > > Why is Chef::Config[:data\_bag\_path] an array?
> > > 
> > > - because you can have multiple folder containing the data bags. this is  
> > > similar to cookbook\_path. In your case you can just use .first.  
> > > Recursive directory and permission:
> > > - If any of the parent directory exist should Chef change its  
> > > permission? Is that intended? If chef creates one of the parent directory  
> > > the dafault permissions will govern by umask etc.. should chef change  
> > > that? Current behavior is to leave them as it is (or let umask govern  
> > > them). I find it safer
> > > 
> > > just curious why you are trying to create data bag paths?
> > > 
> > > On Thu, Feb 26, 2015 at 10:19 AM, Fabien Delpierre \<  
> > > [fabien.delpierre@gmail.com](mailto:fabien.delpierre@gmail.com)\> wrote:
> > > 
> > > > Thanks.  
> > > > Why is Chef::Config[:data\_bag\_path] an array, though?  
> > > > Also, you may have noticed I already have the recursive attribute set  
> > > > to true, but per the docs, it doesn't apply recursive permissions, and I  
> > > > want to set the right permissions on both folders.
> > > > 
> > > > Anyway, I commented out the code I posted earlier and used this instead:
> > > > 
> > > > directory "#{Chef::Config[:data\_bag\_path]}/#{node['nap']['data\_bag']}"  
> > > > do  
> > > > owner node['nap']['provisioning\_owner']  
> > > > group node['nap']['provisioning\_group']  
> > > > mode 00440  
> > > > recursive true  
> > > > action :create  
> > > > end
> > > > 
> > > > The Chef run ran successfully. The run output says:  
> > > > ==\> default: [2015-02-26T13:12:59-05:00] INFO:  
> > > > directory[["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]/nap-vagrant]  
> > > > created directory  
> > > > ["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]/nap-vagrant  
> > > > ==\> default: [2015-02-26T13:12:59-05:00] INFO:  
> > > > directory[["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]/nap-vagrant]  
> > > > owner changed to 500  
> > > > ==\> default: [2015-02-26T13:12:59-05:00] INFO:  
> > > > directory[["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]/nap-vagrant]  
> > > > group changed to 0  
> > > > ==\> default: [2015-02-26T13:12:59-05:00] INFO:  
> > > > directory[["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]/nap-vagrant]  
> > > > mode changed to 440
> > > > 
> > > > You can see the brackets are still there and it looks fishy. Sure  
> > > > enough, /tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags does  
> > > > not exist. However I now have a folder directly under / called '["' with  
> > > > the above directory structure underneath it, i.e.  
> > > > /["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]
> > > > 
> > > > So I'm still in trouble 🙂
> > > > 
> > > > On Thu, Feb 26, 2015 at 1:03 PM, Brandon Raabe [brandocorp@gmail.com](mailto:brandocorp@gmail.com)  
> > > > wrote:
> > > > 
> > > > > It looks like your first entry is an array.
> > > > > 
> > > > > dirs = [_Chef::Config[:data\_bag\_path]_, "#{Chef::Config[:data\_bag\_path]}/#{node['data\_bag']}"  
> > > > > ]
> > > > > 
> > > > > directory("\*["/tmp/vagrant-\*_chef/c0f72feb81f20d85ca657a73371fce_  
> > > > > _cb/data\_bags"]_") do
> > > > > 
> > > > > You can force it to create the entire path by adding the recursive  
> > > > > attribute to you directory resource.
> > > > > 
> > > > > On Thu, Feb 26, 2015 at 10:40 AM, Fabien Delpierre \<  
> > > > > [fabien.delpierre@gmail.com](mailto:fabien.delpierre@gmail.com)\> wrote:
> > > > > 
> > > > > > Hi there,  
> > > > > > I can't figure out what I'm doing wrong with this. It seems trivial  
> > > > > > enough but I'm not a software developer and this is puzzling me right now.  
> > > > > > I think my issue has more to do with pure Ruby than Chef but either way, I  
> > > > > > can't figure it out.  
> > > > > > If it matters, I'm working with chef-solo 12.0.3 and provisioning  
> > > > > > things via Vagrant 1.7.2.
> > > > > > 
> > > > > > I'm doing something that should be pretty straightforward: creating a  
> > > > > > number of directories declared in an array:
> > > > > > 
> > > > > > dirs = [Chef::Config[:data\_bag\_path],  
> > > > > > "#{Chef::Config[:data\_bag\_path]}/#{node['data\_bag']}" ]
> > > > > > 
> > > > > > dirs.each do |dir|  
> > > > > > directory dir do  
> > > > > > owner "foo"  
> > > > > > group "foo"  
> > > > > > mode 00440  
> > > > > > recursive true  
> > > > > > action :create  
> > > > > > end  
> > > > > > end
> > > > > > 
> > > > > > This results in the following error during provisioning  
> > > > > > ==\> default: Compiled Resource:  
> > > > > > ==\> default: ------------------  
> > > > > > ==\> default: # Declared in  
> > > > > > /tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/cookbooks/nap/recipes/default.rb:90:in  
> > > > > > `block in from\_file'  
> > > > > > ==\> default:  
> > > > > > ==\> default:  
> > > > > > directory("["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]")  
> > > > > > do  
> > > > > > ==\> default: action [:create]  
> > > > > > ==\> default: retries 0  
> > > > > > ==\> default: retry\_delay 2  
> > > > > > ==\> default: default\_guard\_interpreter :default  
> > > > > > ==\> default: path  
> > > > > > ["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]  
> > > > > > ==\> default: recursive true  
> > > > > > ==\> default: declared\_type :directory  
> > > > > > ==\> default: cookbook\_name :nap  
> > > > > > ==\> default: recipe\_name "default"  
> > > > > > ==\> default: owner "foo"  
> > > > > > ==\> default: group "foo"  
> > > > > > ==\> default: mode 288  
> > > > > > ==\> default: end  
> > > > > > ==\> default:  
> > > > > > ==\> default: [2015-02-26T12:09:20-05:00] INFO: Running queued delayed  
> > > > > > notifications before re-raising exception  
> > > > > > ==\> default: [2015-02-26T12:09:20-05:00] ERROR: Running exception  
> > > > > > handlers  
> > > > > > ==\> default: [2015-02-26T12:09:20-05:00] ERROR: Exception handlers  
> > > > > > complete  
> > > > > > ==\> default: [2015-02-26T12:09:20-05:00] FATAL: Stacktrace dumped to  
> > > > > > /var/chef/cache/chef-stacktrace.out  
> > > > > > ==\> default: [2015-02-26T12:09:20-05:00] ERROR:  
> > > > > > directory[["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]]  
> > > > > > (nap::default line 90) had an error: Chef::Exceptions::ValidationFailed:  
> > > > > > Option path must be a kind of String! You passed  
> > > > > > ["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"].  
> > > > > > ==\> default: [2015-02-26T12:09:21-05:00] FATAL:  
> > > > > > Chef::Exceptions::ChildConvergeError: Chef run process exited  
> > > > > > unsuccessfully (exit code 1)
> > > > > > 
> > > > > > I ran this through chef-shell as well:  
> > > > > > $ chef-shell -s -c solo.rb  
> > > > > > loading configuration: solo.rb  
> > > > > > Session type: solo  
> > > > > > Loading.............done.  
> > > > > > Ohai2u vagrant@nap-cookbook!  
> > > > > > chef \> puts Chef::Config[:data\_bag\_path]  
> > > > > > /tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags  
> > > > > > =\> nil  
> > > > > > chef \> dirs = [Chef::Config[:data\_bag\_path],  
> > > > > > "#{Chef::Config[:data\_bag\_path]}/#{node['foo']['bar']}" ]  
> > > > > > NoMethodError: undefined method `[]' for nil:NilClass from (irb):3 from /opt/chef/embedded/apps/chef/lib/chef/shell.rb:75:in `block  
> > > > > > in start'  
> > > > > > from /opt/chef/embedded/apps/chef/lib/chef/shell.rb:74:in `catch' from /opt/chef/embedded/apps/chef/lib/chef/shell.rb:74:in `start'  
> > > > > > from /opt/chef/embedded/apps/chef/bin/chef-shell:37:in `<top (required)>' from /usr/bin/chef-shell:40:in `load'  
> > > > > > from /usr/bin/chef-shell:40:in `'  
> > > > > > chef \> dirs =   
> > > > > > =\>   
> > > > > > chef \> dirs = [Chef::Config[:data\_bag\_path] ]  
> > > > > > =\> [["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]]  
> > > > > > chef \> puts dirs  
> > > > > > /tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags  
> > > > > > =\> nil  
> > > > > > chef \> dirs = [Chef::Config[:data\_bag\_path],  
> > > > > > "#{Chef::Config[:data\_bag\_path]}/test" ]  
> > > > > > =\>  
> > > > > > [["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"],  
> > > > > > "["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]/test"]  
> > > > > > chef \> puts dirs  
> > > > > > /tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags  
> > > > > > ["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]/test  
> > > > > > =\> nil  
> > > > > > chef \>
> > > > > > 
> > > > > > So as you can see in the above output, it's adding brackets around  
> > > > > > some of the things stored in the array and that seems to be why the Chef  
> > > > > > run is failing, but I don't understand why adding the brackets to begin  
> > > > > > with.
> > > > > > 
> > > > > > I also have no idea why this line produces an error:  
> > > > > > chef \> dirs = [Chef::Config[:data\_bag\_path],  
> > > > > > "#{Chef::Config[:data\_bag\_path]}/#{node['foo']['bar']}" ]
> > > > > > 
> > > > > > Would somebody please mind explaining what I'm doing wrong? Thank you!

---

<div class="post-metadata">

**Author:** ![Brandon\_Raabe](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/brandon_raabe/32/40_2.png) [@Brandon\_Raabe](https://discourse.chef.io/u/Brandon_Raabe)\
**Post date:** [February 27, 2015, 4:52am UTC](https://discourse.chef.io/t/malformed-array-causing-chef-to-error-out/6354/10 "2015-02-27T04:52:22Z")

</div>

My only experience with chef-solo is while using vagrant or test-kitchen,  
and in both of those cases, the cookbooks and data bags are pushed to the  
target machine prior to the chef run. It looks like you're using vagrant,  
either directly or via test kitchen. You can set your configuration to  
upload the data bags you need for you chef run.

If you're using vagrant, you'll want to set the following:

Vagrant.configure("2") do |config|  
config.vm.provision "chef\_solo" do |chef|  
chef.data\_bags\_path = "data\_bags"  
end  
end

If you're using Test Kitchen, you can set the following:

* * *

driver:  
name: vagrant

provisioner:  
name: chef\_solo

suites:

- name: default  
data\_bags\_path: "data\_bags"

Getting back to your original issue, you were trying to create two  
directories. The first was the actual data\_bags folder, and the second was  
the nested data bag folder. The first failure you received was because the  
first element in your dirs array was an array. This caused the directory  
resource to fail because the path attribute was not a string value.

The second attempt you hard coded path to the nested data bag folder, but  
still received an error because the string interpolation for the array  
value gave you a funky path, which was created, but was not what you were  
expecting.

If you try the following code in your recipe, does it work?

data\_bags\_path = Chef::Config[:data\_bag\_path].first  
dirs = ["#{data\_bags\_path}/#{node['data\_bag']}" ]

dirs.each do |dir|  
directory dir do  
owner "vagrant"  
group "root"  
mode 0755  
recursive true  
action :create  
end  
end

On Thu, Feb 26, 2015 at 4:59 PM, Fabien Delpierre \<  
[fabien.delpierre@gmail.com](mailto:fabien.delpierre@gmail.com)\> wrote:

> I prefer to use the execute resource as a last resort, I don't see what  
> advantage it would give me over using the directory, file or template  
> resources with owner and group attributes?
> 
> On Thu, Feb 26, 2015 at 5:36 PM, Ranjib Dey [dey.ranjib@gmail.com](mailto:dey.ranjib@gmail.com) wrote:
> 
> > you can use an execute statement with 'chown -R vagrant:root  
> > /path/to/repo' which will do what you want.  
> > you can try chef-client -z (aka localmode) as well, lot of new work are  
> > happening their, it has solo like semantics.
> > 
> > On Thu, Feb 26, 2015 at 11:30 AM, Fabien Delpierre \<  
> > [fabien.delpierre@gmail.com](mailto:fabien.delpierre@gmail.com)\> wrote:
> > 
> > > Ranjib,  
> > > Perhaps I'm looking at the permissions thing the wrong way, but here's  
> > > how I understand it: I want the files and directories I'm creating to be  
> > > owned by the vagrant user and the root group.  
> > > /tmp/vagrant-chef is owned by vagrant:root, however the directory  
> > > underneath that, /tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb is  
> > > owned by root:root. This is a folder provisioned automatically by  
> > > Vagrant/Berkshelf, not by Chef, and I don't know if I can customize the  
> > > ownership, or how I would do that, nor am I really concerned with that so  
> > > long as it doesn't cause me any trouble 🙂
> > > 
> > > And to your question about why I'm creating data bag paths, well, again,  
> > > perhaps I'm doing it wrong, but they currently don't exist, and I want them  
> > > to exist. I'm using Chef-Solo, not Chef-Client. I'm not new to Chef-Client,  
> > > but I've never used Chef-Solo so I'm still learning the differences.
> > > 
> > > We saw earlier that Chef::Config[:data\_bag\_path].first =  
> > > /tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags but before I  
> > > run this code to create the directories and files I need, there is no  
> > > data\_bags directory under  
> > > /tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb, so I need to create it  
> > > and place a data bag item in it. The reason why I need a data bag at all is  
> > > because I'm trying to store credentials for AWS S3 so I can then use the  
> > > aws\_s3\_file resource from the aws cookbook  
> > > [https://github.com/opscode-cookbooks/aws](https://github.com/opscode-cookbooks/aws). I've never had to use that  
> > > cookbook but it says I should use a data bag to store the AWS credentials.  
> > > I probably don't have to, but I'm going to need to use data bags to store  
> > > some secrets for something else later. Or maybe I don't actually have to  
> > > use data bags for this next thing I'm thinking, but I'll need to figure out  
> > > where to put all the secrets I need to pass to the app for it to work.
> > > 
> > > On Thu, Feb 26, 2015 at 1:48 PM, Ranjib Dey [dey.ranjib@gmail.com](mailto:dey.ranjib@gmail.com)  
> > > wrote:
> > > 
> > > > Why is Chef::Config[:data\_bag\_path] an array?
> > > > 
> > > > - because you can have multiple folder containing the data bags. this  
> > > > is similar to cookbook\_path. In your case you can just use .first.  
> > > > Recursive directory and permission:
> > > > - If any of the parent directory exist should Chef change its  
> > > > permission? Is that intended? If chef creates one of the parent directory  
> > > > the dafault permissions will govern by umask etc.. should chef change  
> > > > that? Current behavior is to leave them as it is (or let umask govern  
> > > > them). I find it safer
> > > > 
> > > > just curious why you are trying to create data bag paths?
> > > > 
> > > > On Thu, Feb 26, 2015 at 10:19 AM, Fabien Delpierre \<  
> > > > [fabien.delpierre@gmail.com](mailto:fabien.delpierre@gmail.com)\> wrote:
> > > > 
> > > > > Thanks.  
> > > > > Why is Chef::Config[:data\_bag\_path] an array, though?  
> > > > > Also, you may have noticed I already have the recursive attribute set  
> > > > > to true, but per the docs, it doesn't apply recursive permissions, and I  
> > > > > want to set the right permissions on both folders.
> > > > > 
> > > > > Anyway, I commented out the code I posted earlier and used this  
> > > > > instead:
> > > > > 
> > > > > directory "#{Chef::Config[:data\_bag\_path]}/#{node['nap']['data\_bag']}"  
> > > > > do  
> > > > > owner node['nap']['provisioning\_owner']  
> > > > > group node['nap']['provisioning\_group']  
> > > > > mode 00440  
> > > > > recursive true  
> > > > > action :create  
> > > > > end
> > > > > 
> > > > > The Chef run ran successfully. The run output says:  
> > > > > ==\> default: [2015-02-26T13:12:59-05:00] INFO:  
> > > > > directory[["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]/nap-vagrant]  
> > > > > created directory  
> > > > > ["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]/nap-vagrant  
> > > > > ==\> default: [2015-02-26T13:12:59-05:00] INFO:  
> > > > > directory[["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]/nap-vagrant]  
> > > > > owner changed to 500  
> > > > > ==\> default: [2015-02-26T13:12:59-05:00] INFO:  
> > > > > directory[["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]/nap-vagrant]  
> > > > > group changed to 0  
> > > > > ==\> default: [2015-02-26T13:12:59-05:00] INFO:  
> > > > > directory[["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]/nap-vagrant]  
> > > > > mode changed to 440
> > > > > 
> > > > > You can see the brackets are still there and it looks fishy. Sure  
> > > > > enough, /tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags does  
> > > > > not exist. However I now have a folder directly under / called '["' with  
> > > > > the above directory structure underneath it, i.e.  
> > > > > /["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]
> > > > > 
> > > > > So I'm still in trouble 🙂
> > > > > 
> > > > > On Thu, Feb 26, 2015 at 1:03 PM, Brandon Raabe [brandocorp@gmail.com](mailto:brandocorp@gmail.com)  
> > > > > wrote:
> > > > > 
> > > > > > It looks like your first entry is an array.
> > > > > > 
> > > > > > dirs = [_Chef::Config[:data\_bag\_path]_, "#{Chef::Config[:data\_bag\_path]}/#{node['data\_bag']}"  
> > > > > > ]
> > > > > > 
> > > > > > directory("\*["/tmp/vagrant-\*_chef/c0f72feb81f20d85ca657a73371fce_  
> > > > > > _cb/data\_bags"]_") do
> > > > > > 
> > > > > > You can force it to create the entire path by adding the recursive  
> > > > > > attribute to you directory resource.
> > > > > > 
> > > > > > On Thu, Feb 26, 2015 at 10:40 AM, Fabien Delpierre \<  
> > > > > > [fabien.delpierre@gmail.com](mailto:fabien.delpierre@gmail.com)\> wrote:
> > > > > > 
> > > > > > > Hi there,  
> > > > > > > I can't figure out what I'm doing wrong with this. It seems trivial  
> > > > > > > enough but I'm not a software developer and this is puzzling me right now.  
> > > > > > > I think my issue has more to do with pure Ruby than Chef but either way, I  
> > > > > > > can't figure it out.  
> > > > > > > If it matters, I'm working with chef-solo 12.0.3 and provisioning  
> > > > > > > things via Vagrant 1.7.2.
> > > > > > > 
> > > > > > > I'm doing something that should be pretty straightforward: creating  
> > > > > > > a number of directories declared in an array:
> > > > > > > 
> > > > > > > dirs = [Chef::Config[:data\_bag\_path],  
> > > > > > > "#{Chef::Config[:data\_bag\_path]}/#{node['data\_bag']}" ]
> > > > > > > 
> > > > > > > dirs.each do |dir|  
> > > > > > > directory dir do  
> > > > > > > owner "foo"  
> > > > > > > group "foo"  
> > > > > > > mode 00440  
> > > > > > > recursive true  
> > > > > > > action :create  
> > > > > > > end  
> > > > > > > end
> > > > > > > 
> > > > > > > This results in the following error during provisioning  
> > > > > > > ==\> default: Compiled Resource:  
> > > > > > > ==\> default: ------------------  
> > > > > > > ==\> default: # Declared in  
> > > > > > > /tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/cookbooks/nap/recipes/default.rb:90:in  
> > > > > > > `block in from\_file'  
> > > > > > > ==\> default:  
> > > > > > > ==\> default:  
> > > > > > > directory("["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]")  
> > > > > > > do  
> > > > > > > ==\> default: action [:create]  
> > > > > > > ==\> default: retries 0  
> > > > > > > ==\> default: retry\_delay 2  
> > > > > > > ==\> default: default\_guard\_interpreter :default  
> > > > > > > ==\> default: path  
> > > > > > > ["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]  
> > > > > > > ==\> default: recursive true  
> > > > > > > ==\> default: declared\_type :directory  
> > > > > > > ==\> default: cookbook\_name :nap  
> > > > > > > ==\> default: recipe\_name "default"  
> > > > > > > ==\> default: owner "foo"  
> > > > > > > ==\> default: group "foo"  
> > > > > > > ==\> default: mode 288  
> > > > > > > ==\> default: end  
> > > > > > > ==\> default:  
> > > > > > > ==\> default: [2015-02-26T12:09:20-05:00] INFO: Running queued  
> > > > > > > delayed notifications before re-raising exception  
> > > > > > > ==\> default: [2015-02-26T12:09:20-05:00] ERROR: Running exception  
> > > > > > > handlers  
> > > > > > > ==\> default: [2015-02-26T12:09:20-05:00] ERROR: Exception handlers  
> > > > > > > complete  
> > > > > > > ==\> default: [2015-02-26T12:09:20-05:00] FATAL: Stacktrace dumped to  
> > > > > > > /var/chef/cache/chef-stacktrace.out  
> > > > > > > ==\> default: [2015-02-26T12:09:20-05:00] ERROR:  
> > > > > > > directory[["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]]  
> > > > > > > (nap::default line 90) had an error: Chef::Exceptions::ValidationFailed:  
> > > > > > > Option path must be a kind of String! You passed  
> > > > > > > ["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"].  
> > > > > > > ==\> default: [2015-02-26T12:09:21-05:00] FATAL:  
> > > > > > > Chef::Exceptions::ChildConvergeError: Chef run process exited  
> > > > > > > unsuccessfully (exit code 1)
> > > > > > > 
> > > > > > > I ran this through chef-shell as well:  
> > > > > > > $ chef-shell -s -c solo.rb  
> > > > > > > loading configuration: solo.rb  
> > > > > > > Session type: solo  
> > > > > > > Loading.............done.  
> > > > > > > Ohai2u vagrant@nap-cookbook!  
> > > > > > > chef \> puts Chef::Config[:data\_bag\_path]  
> > > > > > > /tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags  
> > > > > > > =\> nil  
> > > > > > > chef \> dirs = [Chef::Config[:data\_bag\_path],  
> > > > > > > "#{Chef::Config[:data\_bag\_path]}/#{node['foo']['bar']}" ]  
> > > > > > > NoMethodError: undefined method `[]' for nil:NilClass from (irb):3 from /opt/chef/embedded/apps/chef/lib/chef/shell.rb:75:in `block  
> > > > > > > in start'  
> > > > > > > from /opt/chef/embedded/apps/chef/lib/chef/shell.rb:74:in `catch' from /opt/chef/embedded/apps/chef/lib/chef/shell.rb:74:in `start'  
> > > > > > > from /opt/chef/embedded/apps/chef/bin/chef-shell:37:in `<top (required)>' from /usr/bin/chef-shell:40:in `load'  
> > > > > > > from /usr/bin/chef-shell:40:in `'  
> > > > > > > chef \> dirs =   
> > > > > > > =\>   
> > > > > > > chef \> dirs = [Chef::Config[:data\_bag\_path] ]  
> > > > > > > =\>  
> > > > > > > [["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]]  
> > > > > > > chef \> puts dirs  
> > > > > > > /tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags  
> > > > > > > =\> nil  
> > > > > > > chef \> dirs = [Chef::Config[:data\_bag\_path],  
> > > > > > > "#{Chef::Config[:data\_bag\_path]}/test" ]  
> > > > > > > =\>  
> > > > > > > [["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"],  
> > > > > > > "["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]/test"]  
> > > > > > > chef \> puts dirs  
> > > > > > > /tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags  
> > > > > > > ["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]/test  
> > > > > > > =\> nil  
> > > > > > > chef \>
> > > > > > > 
> > > > > > > So as you can see in the above output, it's adding brackets around  
> > > > > > > some of the things stored in the array and that seems to be why the Chef  
> > > > > > > run is failing, but I don't understand why adding the brackets to begin  
> > > > > > > with.
> > > > > > > 
> > > > > > > I also have no idea why this line produces an error:  
> > > > > > > chef \> dirs = [Chef::Config[:data\_bag\_path],  
> > > > > > > "#{Chef::Config[:data\_bag\_path]}/#{node['foo']['bar']}" ]
> > > > > > > 
> > > > > > > Would somebody please mind explaining what I'm doing wrong? Thank  
> > > > > > > you!

---

<div class="post-metadata">

**Author:** ![Shubby](https://avatars.discourse-cdn.com/v4/letter/s/f9ae1b/32.png) [@Shubby](https://discourse.chef.io/u/Shubby)\
**Post date:** [February 27, 2015, 1:54pm UTC](https://discourse.chef.io/t/malformed-array-causing-chef-to-error-out/6354/11 "2015-02-27T13:54:28Z")

</div>

Yes, I'm good to go after adding .first! Sorry if I wasn't clear in my last  
response to you. Thanks!

On Thu, Feb 26, 2015 at 11:52 PM, Brandon Raabe [brandocorp@gmail.com](mailto:brandocorp@gmail.com)  
wrote:

> My only experience with chef-solo is while using vagrant or test-kitchen,  
> and in both of those cases, the cookbooks and data bags are pushed to the  
> target machine prior to the chef run. It looks like you're using vagrant,  
> either directly or via test kitchen. You can set your configuration to  
> upload the data bags you need for you chef run.
> 
> If you're using vagrant, you'll want to set the following:
> 
> Vagrant.configure("2") do |config|  
> config.vm.provision "chef\_solo" do |chef|  
> chef.data\_bags\_path = "data\_bags"  
> end  
> end
> 
> If you're using Test Kitchen, you can set the following:
> 
> * * *
> 
> driver:  
> name: vagrant
> 
> provisioner:  
> name: chef\_solo
> 
> suites:
> 
> - name: default  
> data\_bags\_path: "data\_bags"
> 
> Getting back to your original issue, you were trying to create two  
> directories. The first was the actual data\_bags folder, and the second was  
> the nested data bag folder. The first failure you received was because the  
> first element in your dirs array was an array. This caused the directory  
> resource to fail because the path attribute was not a string value.
> 
> The second attempt you hard coded path to the nested data bag folder, but  
> still received an error because the string interpolation for the array  
> value gave you a funky path, which was created, but was not what you were  
> expecting.
> 
> If you try the following code in your recipe, does it work?
> 
> data\_bags\_path = Chef::Config[:data\_bag\_path].first  
> dirs = ["#{data\_bags\_path}/#{node['data\_bag']}" ]
> 
> dirs.each do |dir|  
> directory dir do  
> owner "vagrant"  
> group "root"  
> mode 0755  
> recursive true  
> action :create  
> end  
> end
> 
> On Thu, Feb 26, 2015 at 4:59 PM, Fabien Delpierre \<  
> [fabien.delpierre@gmail.com](mailto:fabien.delpierre@gmail.com)\> wrote:
> 
> > I prefer to use the execute resource as a last resort, I don't see what  
> > advantage it would give me over using the directory, file or template  
> > resources with owner and group attributes?
> > 
> > On Thu, Feb 26, 2015 at 5:36 PM, Ranjib Dey [dey.ranjib@gmail.com](mailto:dey.ranjib@gmail.com) wrote:
> > 
> > > you can use an execute statement with 'chown -R vagrant:root  
> > > /path/to/repo' which will do what you want.  
> > > you can try chef-client -z (aka localmode) as well, lot of new work are  
> > > happening their, it has solo like semantics.
> > > 
> > > On Thu, Feb 26, 2015 at 11:30 AM, Fabien Delpierre \<  
> > > [fabien.delpierre@gmail.com](mailto:fabien.delpierre@gmail.com)\> wrote:
> > > 
> > > > Ranjib,  
> > > > Perhaps I'm looking at the permissions thing the wrong way, but here's  
> > > > how I understand it: I want the files and directories I'm creating to be  
> > > > owned by the vagrant user and the root group.  
> > > > /tmp/vagrant-chef is owned by vagrant:root, however the directory  
> > > > underneath that, /tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb is  
> > > > owned by root:root. This is a folder provisioned automatically by  
> > > > Vagrant/Berkshelf, not by Chef, and I don't know if I can customize the  
> > > > ownership, or how I would do that, nor am I really concerned with that so  
> > > > long as it doesn't cause me any trouble 🙂
> > > > 
> > > > And to your question about why I'm creating data bag paths, well,  
> > > > again, perhaps I'm doing it wrong, but they currently don't exist, and I  
> > > > want them to exist. I'm using Chef-Solo, not Chef-Client. I'm not new to  
> > > > Chef-Client, but I've never used Chef-Solo so I'm still learning the  
> > > > differences.
> > > > 
> > > > We saw earlier that Chef::Config[:data\_bag\_path].first =  
> > > > /tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags but before I  
> > > > run this code to create the directories and files I need, there is no  
> > > > data\_bags directory under  
> > > > /tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb, so I need to create it  
> > > > and place a data bag item in it. The reason why I need a data bag at all is  
> > > > because I'm trying to store credentials for AWS S3 so I can then use the  
> > > > aws\_s3\_file resource from the aws cookbook  
> > > > [https://github.com/opscode-cookbooks/aws](https://github.com/opscode-cookbooks/aws). I've never had to use that  
> > > > cookbook but it says I should use a data bag to store the AWS credentials.  
> > > > I probably don't have to, but I'm going to need to use data bags to store  
> > > > some secrets for something else later. Or maybe I don't actually have to  
> > > > use data bags for this next thing I'm thinking, but I'll need to figure out  
> > > > where to put all the secrets I need to pass to the app for it to work.
> > > > 
> > > > On Thu, Feb 26, 2015 at 1:48 PM, Ranjib Dey [dey.ranjib@gmail.com](mailto:dey.ranjib@gmail.com)  
> > > > wrote:
> > > > 
> > > > > Why is Chef::Config[:data\_bag\_path] an array?
> > > > > 
> > > > > - because you can have multiple folder containing the data bags. this  
> > > > > is similar to cookbook\_path. In your case you can just use .first.  
> > > > > Recursive directory and permission:
> > > > > - If any of the parent directory exist should Chef change its  
> > > > > permission? Is that intended? If chef creates one of the parent directory  
> > > > > the dafault permissions will govern by umask etc.. should chef change  
> > > > > that? Current behavior is to leave them as it is (or let umask govern  
> > > > > them). I find it safer
> > > > > 
> > > > > just curious why you are trying to create data bag paths?
> > > > > 
> > > > > On Thu, Feb 26, 2015 at 10:19 AM, Fabien Delpierre \<  
> > > > > [fabien.delpierre@gmail.com](mailto:fabien.delpierre@gmail.com)\> wrote:
> > > > > 
> > > > > > Thanks.  
> > > > > > Why is Chef::Config[:data\_bag\_path] an array, though?  
> > > > > > Also, you may have noticed I already have the recursive attribute set  
> > > > > > to true, but per the docs, it doesn't apply recursive permissions, and I  
> > > > > > want to set the right permissions on both folders.
> > > > > > 
> > > > > > Anyway, I commented out the code I posted earlier and used this  
> > > > > > instead:
> > > > > > 
> > > > > > directory  
> > > > > > "#{Chef::Config[:data\_bag\_path]}/#{node['nap']['data\_bag']}" do  
> > > > > > owner node['nap']['provisioning\_owner']  
> > > > > > group node['nap']['provisioning\_group']  
> > > > > > mode 00440  
> > > > > > recursive true  
> > > > > > action :create  
> > > > > > end
> > > > > > 
> > > > > > The Chef run ran successfully. The run output says:  
> > > > > > ==\> default: [2015-02-26T13:12:59-05:00] INFO:  
> > > > > > directory[["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]/nap-vagrant]  
> > > > > > created directory  
> > > > > > ["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]/nap-vagrant  
> > > > > > ==\> default: [2015-02-26T13:12:59-05:00] INFO:  
> > > > > > directory[["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]/nap-vagrant]  
> > > > > > owner changed to 500  
> > > > > > ==\> default: [2015-02-26T13:12:59-05:00] INFO:  
> > > > > > directory[["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]/nap-vagrant]  
> > > > > > group changed to 0  
> > > > > > ==\> default: [2015-02-26T13:12:59-05:00] INFO:  
> > > > > > directory[["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]/nap-vagrant]  
> > > > > > mode changed to 440
> > > > > > 
> > > > > > You can see the brackets are still there and it looks fishy. Sure  
> > > > > > enough, /tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags does  
> > > > > > not exist. However I now have a folder directly under / called '["' with  
> > > > > > the above directory structure underneath it, i.e.  
> > > > > > /["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]
> > > > > > 
> > > > > > So I'm still in trouble 🙂
> > > > > > 
> > > > > > On Thu, Feb 26, 2015 at 1:03 PM, Brandon Raabe [brandocorp@gmail.com](mailto:brandocorp@gmail.com)  
> > > > > > wrote:
> > > > > > 
> > > > > > > It looks like your first entry is an array.
> > > > > > > 
> > > > > > > dirs = [_Chef::Config[:data\_bag\_path]_, "#{Chef::Config[:data\_bag\_path]}/#{node['data\_bag']}"  
> > > > > > > ]
> > > > > > > 
> > > > > > > directory("\*["/tmp/vagrant-\*_chef/c0f72feb81f20d85ca657a73371fce_  
> > > > > > > _cb/data\_bags"]_") do
> > > > > > > 
> > > > > > > You can force it to create the entire path by adding the recursive  
> > > > > > > attribute to you directory resource.
> > > > > > > 
> > > > > > > On Thu, Feb 26, 2015 at 10:40 AM, Fabien Delpierre \<  
> > > > > > > [fabien.delpierre@gmail.com](mailto:fabien.delpierre@gmail.com)\> wrote:
> > > > > > > 
> > > > > > > > Hi there,  
> > > > > > > > I can't figure out what I'm doing wrong with this. It seems trivial  
> > > > > > > > enough but I'm not a software developer and this is puzzling me right now.  
> > > > > > > > I think my issue has more to do with pure Ruby than Chef but either way, I  
> > > > > > > > can't figure it out.  
> > > > > > > > If it matters, I'm working with chef-solo 12.0.3 and provisioning  
> > > > > > > > things via Vagrant 1.7.2.
> > > > > > > > 
> > > > > > > > I'm doing something that should be pretty straightforward: creating  
> > > > > > > > a number of directories declared in an array:
> > > > > > > > 
> > > > > > > > dirs = [Chef::Config[:data\_bag\_path],  
> > > > > > > > "#{Chef::Config[:data\_bag\_path]}/#{node['data\_bag']}" ]
> > > > > > > > 
> > > > > > > > dirs.each do |dir|  
> > > > > > > > directory dir do  
> > > > > > > > owner "foo"  
> > > > > > > > group "foo"  
> > > > > > > > mode 00440  
> > > > > > > > recursive true  
> > > > > > > > action :create  
> > > > > > > > end  
> > > > > > > > end
> > > > > > > > 
> > > > > > > > This results in the following error during provisioning  
> > > > > > > > ==\> default: Compiled Resource:  
> > > > > > > > ==\> default: ------------------  
> > > > > > > > ==\> default: # Declared in  
> > > > > > > > /tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/cookbooks/nap/recipes/default.rb:90:in  
> > > > > > > > `block in from\_file'  
> > > > > > > > ==\> default:  
> > > > > > > > ==\> default:  
> > > > > > > > directory("["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]")  
> > > > > > > > do  
> > > > > > > > ==\> default: action [:create]  
> > > > > > > > ==\> default: retries 0  
> > > > > > > > ==\> default: retry\_delay 2  
> > > > > > > > ==\> default: default\_guard\_interpreter :default  
> > > > > > > > ==\> default: path  
> > > > > > > > ["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]  
> > > > > > > > ==\> default: recursive true  
> > > > > > > > ==\> default: declared\_type :directory  
> > > > > > > > ==\> default: cookbook\_name :nap  
> > > > > > > > ==\> default: recipe\_name "default"  
> > > > > > > > ==\> default: owner "foo"  
> > > > > > > > ==\> default: group "foo"  
> > > > > > > > ==\> default: mode 288  
> > > > > > > > ==\> default: end  
> > > > > > > > ==\> default:  
> > > > > > > > ==\> default: [2015-02-26T12:09:20-05:00] INFO: Running queued  
> > > > > > > > delayed notifications before re-raising exception  
> > > > > > > > ==\> default: [2015-02-26T12:09:20-05:00] ERROR: Running exception  
> > > > > > > > handlers  
> > > > > > > > ==\> default: [2015-02-26T12:09:20-05:00] ERROR: Exception handlers  
> > > > > > > > complete  
> > > > > > > > ==\> default: [2015-02-26T12:09:20-05:00] FATAL: Stacktrace dumped  
> > > > > > > > to /var/chef/cache/chef-stacktrace.out  
> > > > > > > > ==\> default: [2015-02-26T12:09:20-05:00] ERROR:  
> > > > > > > > directory[["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]]  
> > > > > > > > (nap::default line 90) had an error: Chef::Exceptions::ValidationFailed:  
> > > > > > > > Option path must be a kind of String! You passed  
> > > > > > > > ["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"].  
> > > > > > > > ==\> default: [2015-02-26T12:09:21-05:00] FATAL:  
> > > > > > > > Chef::Exceptions::ChildConvergeError: Chef run process exited  
> > > > > > > > unsuccessfully (exit code 1)
> > > > > > > > 
> > > > > > > > I ran this through chef-shell as well:  
> > > > > > > > $ chef-shell -s -c solo.rb  
> > > > > > > > loading configuration: solo.rb  
> > > > > > > > Session type: solo  
> > > > > > > > Loading.............done.  
> > > > > > > > Ohai2u vagrant@nap-cookbook!  
> > > > > > > > chef \> puts Chef::Config[:data\_bag\_path]  
> > > > > > > > /tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags  
> > > > > > > > =\> nil  
> > > > > > > > chef \> dirs = [Chef::Config[:data\_bag\_path],  
> > > > > > > > "#{Chef::Config[:data\_bag\_path]}/#{node['foo']['bar']}" ]  
> > > > > > > > NoMethodError: undefined method `[]' for nil:NilClass from (irb):3 from /opt/chef/embedded/apps/chef/lib/chef/shell.rb:75:in `block in start'  
> > > > > > > > from /opt/chef/embedded/apps/chef/lib/chef/shell.rb:74:in  
> > > > > > > > `catch' from /opt/chef/embedded/apps/chef/lib/chef/shell.rb:74:in `start'  
> > > > > > > > from /opt/chef/embedded/apps/chef/bin/chef-shell:37:in `<top (required)>' from /usr/bin/chef-shell:40:in `load'  
> > > > > > > > from /usr/bin/chef-shell:40:in `'  
> > > > > > > > chef \> dirs =   
> > > > > > > > =\>   
> > > > > > > > chef \> dirs = [Chef::Config[:data\_bag\_path] ]  
> > > > > > > > =\>  
> > > > > > > > [["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]]  
> > > > > > > > chef \> puts dirs  
> > > > > > > > /tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags  
> > > > > > > > =\> nil  
> > > > > > > > chef \> dirs = [Chef::Config[:data\_bag\_path],  
> > > > > > > > "#{Chef::Config[:data\_bag\_path]}/test" ]  
> > > > > > > > =\>  
> > > > > > > > [["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"],  
> > > > > > > > "["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]/test"]  
> > > > > > > > chef \> puts dirs  
> > > > > > > > /tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags
> > > > > > > > 
> > > > > > > > ["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data\_bags"]/test  
> > > > > > > > =\> nil  
> > > > > > > > chef \>
> > > > > > > > 
> > > > > > > > So as you can see in the above output, it's adding brackets around  
> > > > > > > > some of the things stored in the array and that seems to be why the Chef  
> > > > > > > > run is failing, but I don't understand why adding the brackets to begin  
> > > > > > > > with.
> > > > > > > > 
> > > > > > > > I also have no idea why this line produces an error:  
> > > > > > > > chef \> dirs = [Chef::Config[:data\_bag\_path],  
> > > > > > > > "#{Chef::Config[:data\_bag\_path]}/#{node['foo']['bar']}" ]
> > > > > > > > 
> > > > > > > > Would somebody please mind explaining what I'm doing wrong? Thank  
> > > > > > > > you!
