# Chef Solo Cookbook Path

**URL:** <https://discourse.chef.io/t/chef-solo-cookbook-path/6274>\
**Category:** Chef Infra (archive)\
**Created:** [February 9, 2015, 7:35pm UTC](https://discourse.chef.io/t/chef-solo-cookbook-path/6274 "2015-02-09T19:35:40Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Douglas\_Garstang](https://avatars.discourse-cdn.com/v4/letter/d/c2a13f/32.png) [@Douglas\_Garstang](https://discourse.chef.io/u/Douglas_Garstang)\
**Post date:** [February 9, 2015, 7:35pm UTC](https://discourse.chef.io/t/chef-solo-cookbook-path/6274/1 "2015-02-09T19:35:40Z")

</div>

I was trying to write a recipe to configure someone’s chef client with  
chef-solo. The solo.rb has:

cookbook\_path “/home/doug/slice-chef-setup”

That’s about the only thing that seems to work. These don’t:

cookbook\_path "slice-chef-setup"  
cookbook\_path "~/slice-chef-setup"  
cookbook\_path “.” (that really confused chef, as “.” appears to be  
somewhere else.

Running with:  
chef-solo -c solo.rb -o “recipe[slice-chef-setup::default]” -j doug.json

I’ve also tried removing the cookbook path altogether. No help. I’d like to  
make this portable (with real current working directory from users  
perspective). How do I do this?

It would also be nice if I could supply the contents of doug.json on the  
command line. In a file also isn’t very porable.

Doug

---

<div class="post-metadata">

**Author:** ![dcondomitti](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/dcondomitti/32/104_2.png) [@dcondomitti](https://discourse.chef.io/u/dcondomitti)\
**Post date:** [February 9, 2015, 7:40pm UTC](https://discourse.chef.io/t/chef-solo-cookbook-path/6274/2 "2015-02-09T19:40:47Z")

</div>

. refers to the current working directory, not the location of the script. Use File.dirname( **FILE** ) to get the directory containing the script you’re executing. Use File.expand\_path(File.join(“~”, “slice-chef-setup”)) to get the full path to ~/slice-chef-setup

On Monday, February 9, 2015 at 2:35 PM, Douglas Garstang wrote:

> I was trying to write a recipe to configure someone's chef client with chef-solo. The solo.rb has:
> 
> cookbook\_path "/home/doug/slice-chef-setup"
> 
> That's about the only thing that seems to work. These don't:
> 
> cookbook\_path "slice-chef-setup"  
> cookbook\_path "~/slice-chef-setup"  
> cookbook\_path "." (that really confused chef, as "." appears to be somewhere else.
> 
> Running with:  
> chef-solo -c solo.rb -o "recipe[slice-chef-setup::default]" -j doug.json
> 
> I've also tried removing the cookbook path altogether. No help. I'd like to make this portable (with real current working directory from users perspective). How do I do this?
> 
> It would also be nice if I could supply the contents of doug.json on the command line. In a file also isn't very porable.
> 
> Doug

---

<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 9, 2015, 7:43pm UTC](https://discourse.chef.io/t/chef-solo-cookbook-path/6274/3 "2015-02-09T19:43:01Z")

</div>

If you want to do a relative path, you'll need to base it off of where the  
solo.rb file lives

For example if your solo.rb is in /home/doug/.chef/solo.rb

cookbook\_path File.join(File.expand\_path('../../', **FILE** ),  
'slice-chef-setup')

On Mon, Feb 9, 2015 at 12:35 PM, Douglas Garstang [doug.garstang@gmail.com](mailto:doug.garstang@gmail.com)  
wrote:

> I was trying to write a recipe to configure someone's chef client with  
> chef-solo. The solo.rb has:
> 
> cookbook\_path "/home/doug/slice-chef-setup"
> 
> That's about the only thing that seems to work. These don't:
> 
> cookbook\_path "slice-chef-setup"  
> cookbook\_path "~/slice-chef-setup"  
> cookbook\_path "." (that really confused chef, as "." appears to be  
> somewhere else.
> 
> Running with:  
> chef-solo -c solo.rb -o "recipe[slice-chef-setup::default]" -j doug.json
> 
> I've also tried removing the cookbook path altogether. No help. I'd like  
> to make this portable (with real current working directory from users  
> perspective). How do I do this?
> 
> It would also be nice if I could supply the contents of doug.json on the  
> command line. In a file also isn't very porable.
> 
> Doug

---

<div class="post-metadata">

**Author:** ![Douglas\_Garstang](https://avatars.discourse-cdn.com/v4/letter/d/c2a13f/32.png) [@Douglas\_Garstang](https://discourse.chef.io/u/Douglas_Garstang)\
**Post date:** [February 9, 2015, 7:44pm UTC](https://discourse.chef.io/t/chef-solo-cookbook-path/6274/4 "2015-02-09T19:44:48Z")

</div>

Thanks Brandon. Much better.

Might as well throw my next question into this thread. Is there a way to  
display a block of text back to the console at the completion of the solo  
run, without the debug stuff prefixed to the front?

Doug.

On Mon, Feb 9, 2015 at 11:43 AM, Brandon Raabe [brandocorp@gmail.com](mailto:brandocorp@gmail.com) wrote:

> If you want to do a relative path, you'll need to base it off of where the  
> solo.rb file lives
> 
> For example if your solo.rb is in /home/doug/.chef/solo.rb
> 
> cookbook\_path File.join(File.expand\_path('../../', **FILE** ),  
> 'slice-chef-setup')
> 
> On Mon, Feb 9, 2015 at 12:35 PM, Douglas Garstang \<[doug.garstang@gmail.com](mailto:doug.garstang@gmail.com)
> 
> > wrote:
> 
> > I was trying to write a recipe to configure someone's chef client with  
> > chef-solo. The solo.rb has:
> > 
> > cookbook\_path "/home/doug/slice-chef-setup"
> > 
> > That's about the only thing that seems to work. These don't:
> > 
> > cookbook\_path "slice-chef-setup"  
> > cookbook\_path "~/slice-chef-setup"  
> > cookbook\_path "." (that really confused chef, as "." appears to be  
> > somewhere else.
> > 
> > Running with:  
> > chef-solo -c solo.rb -o "recipe[slice-chef-setup::default]" -j doug.json
> > 
> > I've also tried removing the cookbook path altogether. No help. I'd like  
> > to make this portable (with real current working directory from users  
> > perspective). How do I do this?
> > 
> > It would also be nice if I could supply the contents of doug.json on the  
> > command line. In a file also isn't very porable.
> > 
> > Doug

--  
Regards,

Douglas Garstang  
[http://www.linkedin.com/in/garstang](http://www.linkedin.com/in/garstang)  
Email: [doug.garstang@gmail.com](mailto:doug.garstang@gmail.com)  
Cell: +1-805-340-5627

---

<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 9, 2015, 7:52pm UTC](https://discourse.chef.io/t/chef-solo-cookbook-path/6274/5 "2015-02-09T19:52:53Z")

</div>

You could use a report handler to do something like that. Take a look at  
the following for more information:

> **[About Handlers](https://docs.chef.io/handlers/)**
>
> Use a handler to identify situations that arise during a Chef Infra Client run, and then tell Chef Infra Client how to handle these situations when they occur.

[https://supermarket.chef.io/cookbooks/chef\_handler](https://supermarket.chef.io/cookbooks/chef_handler)

On Mon, Feb 9, 2015 at 12:44 PM, Douglas Garstang [doug.garstang@gmail.com](mailto:doug.garstang@gmail.com)  
wrote:

> Thanks Brandon. Much better.
> 
> Might as well throw my next question into this thread. Is there a way to  
> display a block of text back to the console at the completion of the solo  
> run, without the debug stuff prefixed to the front?
> 
> Doug.
> 
> On Mon, Feb 9, 2015 at 11:43 AM, Brandon Raabe [brandocorp@gmail.com](mailto:brandocorp@gmail.com)  
> wrote:
> 
> > If you want to do a relative path, you'll need to base it off of where  
> > the solo.rb file lives
> > 
> > For example if your solo.rb is in /home/doug/.chef/solo.rb
> > 
> > cookbook\_path File.join(File.expand\_path('../../', **FILE** ),  
> > 'slice-chef-setup')
> > 
> > On Mon, Feb 9, 2015 at 12:35 PM, Douglas Garstang \<  
> > [doug.garstang@gmail.com](mailto:doug.garstang@gmail.com)\> wrote:
> > 
> > > I was trying to write a recipe to configure someone's chef client with  
> > > chef-solo. The solo.rb has:
> > > 
> > > cookbook\_path "/home/doug/slice-chef-setup"
> > > 
> > > That's about the only thing that seems to work. These don't:
> > > 
> > > cookbook\_path "slice-chef-setup"  
> > > cookbook\_path "~/slice-chef-setup"  
> > > cookbook\_path "." (that really confused chef, as "." appears to be  
> > > somewhere else.
> > > 
> > > Running with:  
> > > chef-solo -c solo.rb -o "recipe[slice-chef-setup::default]" -j doug.json
> > > 
> > > I've also tried removing the cookbook path altogether. No help. I'd like  
> > > to make this portable (with real current working directory from users  
> > > perspective). How do I do this?
> > > 
> > > It would also be nice if I could supply the contents of doug.json on the  
> > > command line. In a file also isn't very porable.
> > > 
> > > Doug
> 
> --  
> Regards,
> 
> Douglas Garstang  
> [http://www.linkedin.com/in/garstang](http://www.linkedin.com/in/garstang)  
> Email: [doug.garstang@gmail.com](mailto:doug.garstang@gmail.com)  
> Cell: +1-805-340-5627

---

<div class="post-metadata">

**Author:** ![Douglas\_Garstang](https://avatars.discourse-cdn.com/v4/letter/d/c2a13f/32.png) [@Douglas\_Garstang](https://discourse.chef.io/u/Douglas_Garstang)\
**Post date:** [February 9, 2015, 7:56pm UTC](https://discourse.chef.io/t/chef-solo-cookbook-path/6274/6 "2015-02-09T19:56:36Z")

</div>

Ah. I've looked at the chef handler stuff many times. I still have no clue  
how to implement any of it unfortunately.

On Mon, Feb 9, 2015 at 11:52 AM, Brandon Raabe [brandocorp@gmail.com](mailto:brandocorp@gmail.com) wrote:

> You could use a report handler to do something like that. Take a look at  
> the following for more information:
> 
> [About Handlers](https://docs.chef.io/handlers.html)  
> [chef\_handler versions](https://supermarket.chef.io/cookbooks/chef_handler)
> 
> On Mon, Feb 9, 2015 at 12:44 PM, Douglas Garstang \<[doug.garstang@gmail.com](mailto:doug.garstang@gmail.com)
> 
> > wrote:
> 
> > Thanks Brandon. Much better.
> > 
> > Might as well throw my next question into this thread. Is there a way to  
> > display a block of text back to the console at the completion of the solo  
> > run, without the debug stuff prefixed to the front?
> > 
> > Doug.
> > 
> > On Mon, Feb 9, 2015 at 11:43 AM, Brandon Raabe [brandocorp@gmail.com](mailto:brandocorp@gmail.com)  
> > wrote:
> > 
> > > If you want to do a relative path, you'll need to base it off of where  
> > > the solo.rb file lives
> > > 
> > > For example if your solo.rb is in /home/doug/.chef/solo.rb
> > > 
> > > cookbook\_path File.join(File.expand\_path('../../', **FILE** ),  
> > > 'slice-chef-setup')
> > > 
> > > On Mon, Feb 9, 2015 at 12:35 PM, Douglas Garstang \<  
> > > [doug.garstang@gmail.com](mailto:doug.garstang@gmail.com)\> wrote:
> > > 
> > > > I was trying to write a recipe to configure someone's chef client with  
> > > > chef-solo. The solo.rb has:
> > > > 
> > > > cookbook\_path "/home/doug/slice-chef-setup"
> > > > 
> > > > That's about the only thing that seems to work. These don't:
> > > > 
> > > > cookbook\_path "slice-chef-setup"  
> > > > cookbook\_path "~/slice-chef-setup"  
> > > > cookbook\_path "." (that really confused chef, as "." appears to be  
> > > > somewhere else.
> > > > 
> > > > Running with:  
> > > > chef-solo -c solo.rb -o "recipe[slice-chef-setup::default]" -j doug.json
> > > > 
> > > > I've also tried removing the cookbook path altogether. No help. I'd  
> > > > like to make this portable (with real current working directory from users  
> > > > perspective). How do I do this?
> > > > 
> > > > It would also be nice if I could supply the contents of doug.json on  
> > > > the command line. In a file also isn't very porable.
> > > > 
> > > > Doug
> > 
> > --  
> > Regards,
> > 
> > Douglas Garstang  
> > [http://www.linkedin.com/in/garstang](http://www.linkedin.com/in/garstang)  
> > Email: [doug.garstang@gmail.com](mailto:doug.garstang@gmail.com)  
> > Cell: +1-805-340-5627

--  
Regards,

Douglas Garstang  
[http://www.linkedin.com/in/garstang](http://www.linkedin.com/in/garstang)  
Email: [doug.garstang@gmail.com](mailto:doug.garstang@gmail.com)  
Cell: +1-805-340-5627
