# application\_ruby cookbook and rbenv

**URL:** <https://discourse.chef.io/t/application-ruby-cookbook-and-rbenv/3932>\
**Category:** Chef Infra (archive)\
**Created:** [May 10, 2013, 5:57pm UTC](https://discourse.chef.io/t/application-ruby-cookbook-and-rbenv/3932 "2013-05-10T17:57:24Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cassiano\_Leal](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/cassiano_leal/32/86_2.png) [@Cassiano\_Leal](https://discourse.chef.io/u/Cassiano_Leal)\
**Post date:** [May 10, 2013, 5:57pm UTC](https://discourse.chef.io/t/application-ruby-cookbook-and-rbenv/3932/1 "2013-05-10T17:57:24Z")

</div>

How do I tell the application\_ruby cookbook to install passenger in a specific rbenv-managed Ruby?

I’m trying to deploy a Rails app in a clean Ubuntu machine. I managed to get rbenv and Ruby 1.9.3-p327 installed leveraging @fnichol’s cookbooks.

What do I have to do to ensure that things get installed to this specific Ruby, and not to the system-wide 1.8 ?

Thanks!

- cassiano

---

<div class="post-metadata">

**Author:** ![Graham\_Christensen](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/graham_christensen/32/401_2.png) [@Graham\_Christensen](https://discourse.chef.io/u/Graham_Christensen)\
**Post date:** [May 10, 2013, 6:02pm UTC](https://discourse.chef.io/t/application-ruby-cookbook-and-rbenv/3932/2 "2013-05-10T18:02:02Z")

</div>

Hi Cassiano,

I actually had to figure this out just today, but for Unicorn. I decided on creating a bundle wrapper script which sources the environment. see this gist for the wrapper: [bundle\_wrapper.rb · GitHub](https://gist.github.com/grahamc/ea63999829ed220923cc)

Unicorn allows passing in a custom bundler command which I did:

unicorn do  
bundler true  
bundle\_command "#{base\_dir}/bundle\_wrapper.sh"  
end

I'm not sure if passenger has something similar which you can take advantage of.

--  
Graham Christensen

On Friday, May 10, 2013 at 1:57 PM, Cassiano Leal wrote:

> The content of the message has not been downloaded yet.

---

<div class="post-metadata">

**Author:** ![Cassiano\_Leal](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/cassiano_leal/32/86_2.png) [@Cassiano\_Leal](https://discourse.chef.io/u/Cassiano_Leal)\
**Post date:** [May 10, 2013, 7:31pm UTC](https://discourse.chef.io/t/application-ruby-cookbook-and-rbenv/3932/3 "2013-05-10T19:31:22Z")

</div>

Hi Graham,

As I said on IRC, your solution doesn't seem to apply to passenger.

I'm installing rbenv and Ruby using the rbenv cookbook found in the community site. It has an Ohai plugin that correctly reports my rbenv-installed Ruby in languages[:ruby], yet the gem still gets installed to the system Ruby, and when mod\_rails tries to compile it uses that as well.

I'm very curious to understand how are people configuring and deploying Rails applications with Chef. If anyone can share how they're doing it, I'd appreciate that.

Thanks,

- cassiano

On Friday, May 10, 2013 at 15:02, Graham Christensen wrote:

> Hi Cassiano,
> 
> I actually had to figure this out just today, but for Unicorn. I decided on creating a bundle wrapper script which sources the environment. see this gist for the wrapper: [bundle\_wrapper.rb · GitHub](https://gist.github.com/grahamc/ea63999829ed220923cc)
> 
> Unicorn allows passing in a custom bundler command which I did:
> 
> unicorn do  
> bundler true  
> bundle\_command "#{base\_dir}/bundle\_wrapper.sh (http://bundle\_wrapper.sh)"  
> end
> 
> I'm not sure if passenger has something similar which you can take advantage of.
> 
> --  
> Graham Christensen
> 
> On Friday, May 10, 2013 at 1:57 PM, Cassiano Leal wrote:
> 
> > The content of the message has not been downloaded yet.

---

<div class="post-metadata">

**Author:** ![Mathieu\_Martin](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/mathieu_martin/32/60_2.png) [@Mathieu\_Martin](https://discourse.chef.io/u/Mathieu_Martin)\
**Post date:** [May 10, 2013, 10:14pm UTC](https://discourse.chef.io/t/application-ruby-cookbook-and-rbenv/3932/4 "2013-05-10T22:14:57Z")

</div>

Hey Cassiano,

Not sure if this will apply to application\_ruby, but you can see effective  
use of rbenv and both Unicorn and Passenger in [github.com/teohm/rackbox](http://github.com/teohm/rackbox).

Hope this helps,

Mat

On Friday, May 10, 2013, Cassiano Leal wrote:

> Hi Graham,
> 
> As I said on IRC, your solution doesn't seem to apply to passenger.
> 
> I'm installing rbenv and Ruby using the rbenv cookbook found in the  
> community site. It has an Ohai plugin that correctly reports my  
> rbenv-installed Ruby in languages[:ruby], yet the gem still gets installed  
> to the system Ruby, and when mod\_rails tries to compile it uses that as  
> well.
> 
> I'm very curious to understand how are people configuring and deploying  
> Rails applications with Chef. If anyone can share how they're doing it, I'd  
> appreciate that.
> 
> Thanks,
> 
> - cassiano
> 
> On Friday, May 10, 2013 at 15:02, Graham Christensen wrote:
> 
> Hi Cassiano,
> 
> I actually had to figure this out just today, but for Unicorn. I decided  
> on creating a bundle wrapper script which sources the environment. see this  
> gist for the wrapper: [bundle\_wrapper.rb · GitHub](https://gist.github.com/grahamc/ea63999829ed220923cc)
> 
> Unicorn allows passing in a custom bundler command which I did:
> 
> unicorn do  
> bundler true  
> bundle\_command "#{base\_dir}/bundle\_wrapper.sh"  
> end
> 
> I'm not sure if passenger has something similar which you can take  
> advantage of.
> 
> --  
> Graham Christensen
> 
> On Friday, May 10, 2013 at 1:57 PM, Cassiano Leal wrote:
> 
> The content of the message has not been downloaded yet.

--

--

I'm the founder of Rock Solid Ops Inc, a web consultancy.

My main fields of expertise are Ruby on Rails web development, DevOps and a  
bit of mobile. If you need help scaling, understanding, securing or  
managing your web infrastructure (Rails or not), get in touch!

Connect with me and read testimonials on my  
LinkedIn[http://ca.linkedin.com/in/mathieumartin/](http://ca.linkedin.com/in/mathieumartin/),  
follow me on twitter @webmat [http://twitter.com/webmat](http://twitter.com/webmat), or check out my  
blog at [programblings.com](http://programblings.com)[http://www.programblings.com?utm\_source=email+signature](http://www.programblings.com?utm_source=email+signature)  
.

If you're a tech person, the following may make sense to you.

I'm the author of  
git\_remote\_branch[https://rubygems.org/gems/git\_remote\_branch](https://rubygems.org/gems/git_remote_branch).  
A tool that's been helping common mortals like me share git branches for 5  
years. Downloaded 50 000 times.

I've also contributed to some of the popular libraries in the Rails, jQuery  
and PhoneGap ecosystems:

paperclip, active\_admin, jquery-ujs, jquery-rails, kaminari, AssetSync,  
phonegap-plugin-facebook-connect, shoulda, woulda, jeweler.

If you visit them on GitHub, you'll see my face in the "Contributors"  
section 🙂

---

<div class="post-metadata">

**Author:** ![Cassiano\_Leal](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/cassiano_leal/32/86_2.png) [@Cassiano\_Leal](https://discourse.chef.io/u/Cassiano_Leal)\
**Post date:** [May 11, 2013, 12:54am UTC](https://discourse.chef.io/t/application-ruby-cookbook-and-rbenv/3932/5 "2013-05-11T00:54:08Z")

</div>

Hi Mathieu,

Thanks for sharing. I don't see where passenger or unicorn get installed there, though. Is that done elsewhere in your workflow?

Does anyone have a working example of a cookbook where a specific version of Ruby gets installed, then all gems and other Ruby stuff uses that in a sane way? It seems like there's some rocket science involved to do this with Chef, whereas if I do it manually on a server it's a breeze (install rbenv and ruby, set the global ruby version and voilà!).

What am I missing? I must be missing something very obvious here, can anyone point me to it? 🙂

Thanks,

- cassiano

On Friday, May 10, 2013 at 19:14, Mathieu Martin wrote:

> Hey Cassiano,
> 
> Not sure if this will apply to application\_ruby, but you can see effective use of rbenv and both Unicorn and Passenger in [github.com/teohm/rackbox](http://github.com/teohm/rackbox) ([http://github.com/teohm/rackbox](http://github.com/teohm/rackbox)).
> 
> Hope this helps,
> 
> Mat
> 
> On Friday, May 10, 2013, Cassiano Leal wrote:
> 
> > Hi Graham,
> > 
> > As I said on IRC, your solution doesn't seem to apply to passenger.
> > 
> > I'm installing rbenv and Ruby using the rbenv cookbook found in the community site. It has an Ohai plugin that correctly reports my rbenv-installed Ruby in languages[:ruby], yet the gem still gets installed to the system Ruby, and when mod\_rails tries to compile it uses that as well.
> > 
> > I'm very curious to understand how are people configuring and deploying Rails applications with Chef. If anyone can share how they're doing it, I'd appreciate that.
> > 
> > Thanks,
> > 
> > - cassiano
> > 
> > On Friday, May 10, 2013 at 15:02, Graham Christensen wrote:
> > 
> > > Hi Cassiano,
> > > 
> > > I actually had to figure this out just today, but for Unicorn. I decided on creating a bundle wrapper script which sources the environment. see this gist for the wrapper: [bundle\_wrapper.rb · GitHub](https://gist.github.com/grahamc/ea63999829ed220923cc)
> > > 
> > > Unicorn allows passing in a custom bundler command which I did:
> > > 
> > > unicorn do  
> > > bundler true  
> > > bundle\_command "#{base\_dir}/bundle\_wrapper.sh (http://bundle\_wrapper.sh)"  
> > > end
> > > 
> > > I'm not sure if passenger has something similar which you can take advantage of.
> > > 
> > > --  
> > > Graham Christensen
> > > 
> > > On Friday, May 10, 2013 at 1:57 PM, Cassiano Leal wrote:
> > > 
> > > > The content of the message has not been downloaded yet.
> 
> --
> 
> --
> 
> I'm the founder of Rock Solid Ops Inc, a web consultancy.
> 
> My main fields of expertise are Ruby on Rails web development, DevOps and a bit of mobile. If you need help scaling, understanding, securing or managing your web infrastructure (Rails or not), get in touch!
> 
> Connect with me and read testimonials on my LinkedIn ([Mathieu Martin - Jane Technologies, Inc. | LinkedIn](http://ca.linkedin.com/in/mathieumartin/)), follow me on twitter @webmat ([http://twitter.com/webmat](http://twitter.com/webmat)), or check out my blog at [programblings.com](http://programblings.com) ([Programblings](http://www.programblings.com?utm_source=email+signature)).
> 
> If you're a tech person, the following may make sense to you.
> 
> I'm the author of git\_remote\_branch ([git\_remote\_branch | RubyGems.org | your community gem host](https://rubygems.org/gems/git_remote_branch)). A tool that's been helping common mortals like me share git branches for 5 years. Downloaded 50 000 times.
> 
> I've also contributed to some of the popular libraries in the Rails, jQuery and PhoneGap ecosystems:
> 
> paperclip, active\_admin, jquery-ujs, jquery-rails, kaminari, AssetSync, phonegap-plugin-facebook-connect, shoulda, woulda, jeweler.
> 
> If you visit them on GitHub, you'll see my face in the "Contributors" section 🙂

---

<div class="post-metadata">

**Author:** ![Mathieu\_Martin](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/mathieu_martin/32/60_2.png) [@Mathieu\_Martin](https://discourse.chef.io/u/Mathieu_Martin)\
**Post date:** [May 11, 2013, 1:20am UTC](https://discourse.chef.io/t/application-ruby-cookbook-and-rbenv/3932/6 "2013-05-11T01:20:38Z")

</div>

Btw, for any other onlooker, sorry for the broken link, it should have been  
[GitHub - teohm/rackbox-cookbook: Setup a Rack-based application server to run Unicorn & Passenger apps.](http://github.com/teohm/rackbox-cookbook). For more background, now that I'm on my  
computer, here's the  
article[http://teohm.github.io/blog/2013/04/17/chef-cookbooks-for-busy-ruby-developers/](http://teohm.github.io/blog/2013/04/17/chef-cookbooks-for-busy-ruby-developers/)where  
the author presents his trio of cookbooks {app,rack,data}box.

Cassiano, to answer your specific question: I also looked around a bit  
before it clicked.  
This[https://github.com/teohm/rackbox-cookbook/blob/a755b46dfc6be5996b06ed11fd255557dc9e2e3c/recipes/ruby.rb#L16](https://github.com/teohm/rackbox-cookbook/blob/a755b46dfc6be5996b06ed11fd255557dc9e2e3c/recipes/ruby.rb#L16)is  
the only gem installed by the cookbook. Then either Unicorn or  
Passenger  
are installed as gems from each project's Gemfiles 🙂

Now the reason why the Passenger installation as a project gem works out,  
is that the cookbook then starts Passenger  
standalone[https://github.com/teohm/rackbox-cookbook/blob/a755b46dfc6be5996b06ed11fd255557dc9e2e3c/templates/default/sv-passenger-run.erb#L9](https://github.com/teohm/rackbox-cookbook/blob/a755b46dfc6be5996b06ed11fd255557dc9e2e3c/templates/default/sv-passenger-run.erb#L9)instead  
of having it as an Apache or nginx module 🙂

Now it may not work for everyone\*, but I find the approach pretty nice in  
that it makes things much simpler to get going.

For the record, I personally decided on Unicorn for my current project. All  
my app boxes are dedicated to one single app, so I didn't need Passenger's  
flexibility. So your mileage may vary with this approach.

Mat

- Having Passenger standalone download the nginx source and compiling it  
every time you update the gem may not be everyone's cup of tea...

--

I'm the founder of Rock Solid Ops Inc, a web consultancy.

My main fields of expertise are Ruby on Rails web development, DevOps and a  
bit of mobile. If you need help scaling, understanding, securing or  
managing your web infrastructure (Rails or not), get in touch!

Connect with me and read testimonials on my  
LinkedIn[http://ca.linkedin.com/in/mathieumartin/](http://ca.linkedin.com/in/mathieumartin/),  
follow me on twitter @webmat [http://twitter.com/webmat](http://twitter.com/webmat), or check out my  
blog at [programblings.com](http://programblings.com)[http://www.programblings.com?utm\_source=email+signature](http://www.programblings.com?utm_source=email+signature)  
.

If you're a tech person, the following may make sense to you.

I'm the author of  
git\_remote\_branch[https://rubygems.org/gems/git\_remote\_branch](https://rubygems.org/gems/git_remote_branch).  
A tool that's been helping common mortals like me share git branches for 5  
years. Downloaded 50 000 times.

I've also contributed to some of the popular libraries in the Rails, jQuery  
and PhoneGap ecosystems:

paperclip, active\_admin, jquery-ujs, jquery-rails, kaminari, AssetSync,  
phonegap-plugin-facebook-connect, shoulda, woulda, jeweler.

If you visit them on GitHub, you'll see my face in the "Contributors"  
section 🙂

On Fri, May 10, 2013 at 8:54 PM, Cassiano Leal [cassianoleal@gmail.com](mailto:cassianoleal@gmail.com)wrote:

> Hi Mathieu,
> 
> Thanks for sharing. I don't see where passenger or unicorn get installed  
> there, though. Is that done elsewhere in your workflow?
> 
> Does anyone have a working example of a cookbook where a specific version  
> of Ruby gets installed, then all gems and other Ruby stuff uses that in a  
> sane way? It seems like there's some rocket science involved to do this  
> with Chef, whereas if I do it manually on a server it's a breeze (install  
> rbenv and ruby, set the global ruby version and voilà!).
> 
> What am I missing? I must be missing something very obvious here, can  
> anyone point me to it? 🙂
> 
> Thanks,
> 
> - cassiano
> 
> On Friday, May 10, 2013 at 19:14, Mathieu Martin wrote:
> 
> Hey Cassiano,
> 
> Not sure if this will apply to application\_ruby, but you can see effective  
> use of rbenv and both Unicorn and Passenger in [github.com/teohm/rackbox](http://github.com/teohm/rackbox).
> 
> Hope this helps,
> 
> Mat
> 
> On Friday, May 10, 2013, Cassiano Leal wrote:
> 
> Hi Graham,
> 
> As I said on IRC, your solution doesn't seem to apply to passenger.
> 
> I'm installing rbenv and Ruby using the rbenv cookbook found in the  
> community site. It has an Ohai plugin that correctly reports my  
> rbenv-installed Ruby in languages[:ruby], yet the gem still gets installed  
> to the system Ruby, and when mod\_rails tries to compile it uses that as  
> well.
> 
> I'm very curious to understand how are people configuring and deploying  
> Rails applications with Chef. If anyone can share how they're doing it, I'd  
> appreciate that.
> 
> Thanks,
> 
> - cassiano
> 
> On Friday, May 10, 2013 at 15:02, Graham Christensen wrote:
> 
> Hi Cassiano,
> 
> I actually had to figure this out just today, but for Unicorn. I decided  
> on creating a bundle wrapper script which sources the environment. see this  
> gist for the wrapper: [bundle\_wrapper.rb · GitHub](https://gist.github.com/grahamc/ea63999829ed220923cc)
> 
> Unicorn allows passing in a custom bundler command which I did:
> 
> unicorn do  
> bundler true  
> bundle\_command "#{base\_dir}/bundle\_wrapper.sh"  
> end
> 
> I'm not sure if passenger has something similar which you can take  
> advantage of.
> 
> --  
> Graham Christensen
> 
> On Friday, May 10, 2013 at 1:57 PM, Cassiano Leal wrote:
> 
> The content of the message has not been downloaded yet.
> 
> --
> 
> --
> 
> I'm the founder of Rock Solid Ops Inc, a web consultancy.
> 
> My main fields of expertise are Ruby on Rails web development, DevOps and  
> a bit of mobile. If you need help scaling, understanding, securing or  
> managing your web infrastructure (Rails or not), get in touch!
> 
> Connect with me and read testimonials on my LinkedIn[http://ca.linkedin.com/in/mathieumartin/](http://ca.linkedin.com/in/mathieumartin/),  
> follow me on twitter @webmat [http://twitter.com/webmat](http://twitter.com/webmat), or check out my  
> blog at [programblings.com](http://programblings.com)[http://www.programblings.com?utm\_source=email+signature](http://www.programblings.com?utm_source=email+signature)  
> .
> 
> If you're a tech person, the following may make sense to you.
> 
> I'm the author of git\_remote\_branch[https://rubygems.org/gems/git\_remote\_branch](https://rubygems.org/gems/git_remote_branch).  
> A tool that's been helping common mortals like me share git branches for  
> 5 years. Downloaded 50 000 times.
> 
> I've also contributed to some of the popular libraries in the Rails, jQuery  
> and PhoneGap ecosystems:
> 
> paperclip, active\_admin, jquery-ujs, jquery-rails, kaminari, AssetSync,  
> phonegap-plugin-facebook-connect, shoulda, woulda, jeweler.
> 
> If you visit them on GitHub, you'll see my face in the "Contributors"  
> section 🙂

---

<div class="post-metadata">

**Author:** ![Cassiano\_Leal](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/cassiano_leal/32/86_2.png) [@Cassiano\_Leal](https://discourse.chef.io/u/Cassiano_Leal)\
**Post date:** [May 11, 2013, 2:19am UTC](https://discourse.chef.io/t/application-ruby-cookbook-and-rbenv/3932/7 "2013-05-11T02:19:34Z")

</div>

Hah, I see!

That's an interesting approach, I didn't even recall the existence of Passenger standalone. 🙂 I'll try to adapt this to my setup (with apache instead of nginx and a heavy use of named vhosts) but I guess it'll work out ok.

It still eludes me why it's so difficult to reproduce my current setup in Chef, though.

Thanks for all the pointers, I believe I have enough to get going for now. 🙂

- cassiano

On Friday, May 10, 2013 at 22:20, Mathieu Martin wrote:

> Btw, for any other onlooker, sorry for the broken link, it should have been [GitHub - teohm/rackbox-cookbook: Setup a Rack-based application server to run Unicorn & Passenger apps.](http://github.com/teohm/rackbox-cookbook) ([GitHub - teohm/rackbox-cookbook: Setup a Rack-based application server to run Unicorn & Passenger apps.](http://github.com/teohm/rackbox-cookbook)). For more background, now that I'm on my computer, here's the article ([http://teohm.github.io/blog/2013/04/17/chef-cookbooks-for-busy-ruby-developers/](http://teohm.github.io/blog/2013/04/17/chef-cookbooks-for-busy-ruby-developers/)) where the author presents his trio of cookbooks {app,rack,data}box.
> 
> Cassiano, to answer your specific question: I also looked around a bit before it clicked. This ([rackbox-cookbook/recipes/ruby.rb at a755b46dfc6be5996b06ed11fd255557dc9e2e3c · teohm/rackbox-cookbook · GitHub](https://github.com/teohm/rackbox-cookbook/blob/a755b46dfc6be5996b06ed11fd255557dc9e2e3c/recipes/ruby.rb#L16)) is the only gem installed by the cookbook. Then either Unicorn or Passenger are installed as gems from each project's Gemfiles 🙂
> 
> Now the reason why the Passenger installation as a project gem works out, is that the cookbook then starts Passenger standalone ([rackbox-cookbook/templates/default/sv-passenger-run.erb at a755b46dfc6be5996b06ed11fd255557dc9e2e3c · teohm/rackbox-cookbook · GitHub](https://github.com/teohm/rackbox-cookbook/blob/a755b46dfc6be5996b06ed11fd255557dc9e2e3c/templates/default/sv-passenger-run.erb#L9)) instead of having it as an Apache or nginx module 🙂
> 
> Now it may not work for everyone\*, but I find the approach pretty nice in that it makes things much simpler to get going.
> 
> For the record, I personally decided on Unicorn for my current project. All my app boxes are dedicated to one single app, so I didn't need Passenger's flexibility. So your mileage may vary with this approach.
> 
> Mat
> 
> - Having Passenger standalone download the nginx source and compiling it every time you update the gem may not be everyone's cup of tea...
> 
> --
> 
> I'm the founder of Rock Solid Ops Inc, a web consultancy.
> 
> My main fields of expertise are Ruby on Rails web development, DevOps and a bit of mobile. If you need help scaling, understanding, securing or managing your web infrastructure (Rails or not), get in touch!
> 
> Connect with me and read testimonials on my LinkedIn ([Mathieu Martin - Jane Technologies, Inc. | LinkedIn](http://ca.linkedin.com/in/mathieumartin/)), follow me on twitter @webmat ([http://twitter.com/webmat](http://twitter.com/webmat)), or check out my blog at [programblings.com](http://programblings.com) ([Programblings](http://www.programblings.com?utm_source=email+signature)).
> 
> If you're a tech person, the following may make sense to you.
> 
> I'm the author of git\_remote\_branch ([git\_remote\_branch | RubyGems.org | your community gem host](https://rubygems.org/gems/git_remote_branch)). A tool that's been helping common mortals like me share git branches for 5 years. Downloaded 50 000 times.
> 
> I've also contributed to some of the popular libraries in the Rails, jQuery and PhoneGap ecosystems:
> 
> paperclip, active\_admin, jquery-ujs, jquery-rails, kaminari, AssetSync, phonegap-plugin-facebook-connect, shoulda, woulda, jeweler.
> 
> If you visit them on GitHub, you'll see my face in the "Contributors" section 🙂
> 
> On Fri, May 10, 2013 at 8:54 PM, Cassiano Leal \<[cassianoleal@gmail.com](mailto:cassianoleal@gmail.com) ([mailto:cassianoleal@gmail.com](mailto:cassianoleal@gmail.com))\> wrote:
> 
> > Hi Mathieu,
> > 
> > Thanks for sharing. I don't see where passenger or unicorn get installed there, though. Is that done elsewhere in your workflow?
> > 
> > Does anyone have a working example of a cookbook where a specific version of Ruby gets installed, then all gems and other Ruby stuff uses that in a sane way? It seems like there's some rocket science involved to do this with Chef, whereas if I do it manually on a server it's a breeze (install rbenv and ruby, set the global ruby version and voilà!).
> > 
> > What am I missing? I must be missing something very obvious here, can anyone point me to it? 🙂
> > 
> > Thanks,
> > 
> > - cassiano
> > 
> > On Friday, May 10, 2013 at 19:14, Mathieu Martin wrote:
> > 
> > > Hey Cassiano,
> > > 
> > > Not sure if this will apply to application\_ruby, but you can see effective use of rbenv and both Unicorn and Passenger in [github.com/teohm/rackbox](http://github.com/teohm/rackbox) ([http://github.com/teohm/rackbox](http://github.com/teohm/rackbox)).
> > > 
> > > Hope this helps,
> > > 
> > > Mat
> > > 
> > > On Friday, May 10, 2013, Cassiano Leal wrote:
> > > 
> > > > Hi Graham,
> > > > 
> > > > As I said on IRC, your solution doesn't seem to apply to passenger.
> > > > 
> > > > I'm installing rbenv and Ruby using the rbenv cookbook found in the community site. It has an Ohai plugin that correctly reports my rbenv-installed Ruby in languages[:ruby], yet the gem still gets installed to the system Ruby, and when mod\_rails tries to compile it uses that as well.
> > > > 
> > > > I'm very curious to understand how are people configuring and deploying Rails applications with Chef. If anyone can share how they're doing it, I'd appreciate that.
> > > > 
> > > > Thanks,
> > > > 
> > > > - cassiano
> > > > 
> > > > On Friday, May 10, 2013 at 15:02, Graham Christensen wrote:
> > > > 
> > > > > Hi Cassiano,
> > > > > 
> > > > > I actually had to figure this out just today, but for Unicorn. I decided on creating a bundle wrapper script which sources the environment. see this gist for the wrapper: [bundle\_wrapper.rb · GitHub](https://gist.github.com/grahamc/ea63999829ed220923cc)
> > > > > 
> > > > > Unicorn allows passing in a custom bundler command which I did:
> > > > > 
> > > > > unicorn do  
> > > > > bundler true  
> > > > > bundle\_command "#{base\_dir}/bundle\_wrapper.sh (http://bundle\_wrapper.sh)"  
> > > > > end
> > > > > 
> > > > > I'm not sure if passenger has something similar which you can take advantage of.
> > > > > 
> > > > > --  
> > > > > Graham Christensen
> > > > > 
> > > > > On Friday, May 10, 2013 at 1:57 PM, Cassiano Leal wrote:
> > > > > 
> > > > > > The content of the message has not been downloaded yet.
> > > 
> > > --
> > > 
> > > --
> > > 
> > > I'm the founder of Rock Solid Ops Inc, a web consultancy.
> > > 
> > > My main fields of expertise are Ruby on Rails web development, DevOps and a bit of mobile. If you need help scaling, understanding, securing or managing your web infrastructure (Rails or not), get in touch!
> > > 
> > > Connect with me and read testimonials on my LinkedIn ([Mathieu Martin - Jane Technologies, Inc. | LinkedIn](http://ca.linkedin.com/in/mathieumartin/)), follow me on twitter @webmat ([http://twitter.com/webmat](http://twitter.com/webmat)), or check out my blog at [programblings.com](http://programblings.com) ([Programblings](http://www.programblings.com?utm_source=email+signature)).
> > > 
> > > If you're a tech person, the following may make sense to you.
> > > 
> > > I'm the author of git\_remote\_branch ([git\_remote\_branch | RubyGems.org | your community gem host](https://rubygems.org/gems/git_remote_branch)). A tool that's been helping common mortals like me share git branches for 5 years. Downloaded 50 000 times.
> > > 
> > > I've also contributed to some of the popular libraries in the Rails, jQuery and PhoneGap ecosystems:
> > > 
> > > paperclip, active\_admin, jquery-ujs, jquery-rails, kaminari, AssetSync, phonegap-plugin-facebook-connect, shoulda, woulda, jeweler.
> > > 
> > > If you visit them on GitHub, you'll see my face in the "Contributors" section 🙂

---

<div class="post-metadata">

**Author:** ![Mathieu\_Martin](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/mathieu_martin/32/60_2.png) [@Mathieu\_Martin](https://discourse.chef.io/u/Mathieu_Martin)\
**Post date:** [May 11, 2013, 5:30am UTC](https://discourse.chef.io/t/application-ruby-cookbook-and-rbenv/3932/8 "2013-05-11T05:30:54Z")

</div>

On Fri, May 10, 2013 at 10:19 PM, Cassiano Leal [cassianoleal@gmail.com](mailto:cassianoleal@gmail.com)wrote:

> Hah, I see!
> 
> That's an interesting approach, I didn't even recall the existence of  
> Passenger standalone. 🙂 I'll try to adapt this to my setup (with apache  
> instead of nginx and a heavy use of named vhosts) but I guess it'll work  
> out ok.

Yeah, you can keep using Apache no problem. Just treat Passenger standalone  
as an upstream. The fact that it uses nginx internally is an implementation  
detail 🙂

> It still eludes me why it's so difficult to reproduce my current setup in  
> Chef, though.

I do think some of those cookbooks (e.g. application\_ruby, deploy, nginx w/  
Passenger) don't do enough handholding to help newcomers understand how  
they should be used. I don't use them.

The attributes are all laid out just fine, but I think they could be more  
explicit in detailing the assumptions the cookbook makes about how your app  
works or how you subsequently deploy it.

> Thanks for all the pointers, I believe I have enough to get going for now.  
> 🙂

Glad to be of help!

Mat

---

<div class="post-metadata">

**Author:** ![Cassiano\_Leal](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/cassiano_leal/32/86_2.png) [@Cassiano\_Leal](https://discourse.chef.io/u/Cassiano_Leal)\
**Post date:** [May 11, 2013, 2:17pm UTC](https://discourse.chef.io/t/application-ruby-cookbook-and-rbenv/3932/9 "2013-05-11T14:17:21Z")

</div>

On Saturday, May 11, 2013 at 02:30, Mathieu Martin wrote:

> On Fri, May 10, 2013 at 10:19 PM, Cassiano Leal \<[cassianoleal@gmail.com](mailto:cassianoleal@gmail.com) ([mailto:cassianoleal@gmail.com](mailto:cassianoleal@gmail.com))\> wrote:

> > It still eludes me why it's so difficult to reproduce my current setup in Chef, though.
> 
> I do think some of those cookbooks (e.g. application\_ruby, deploy, nginx w/ Passenger) don't do enough handholding to help newcomers understand how they should be used. I don't use them.
> 
> The attributes are all laid out just fine, but I think they could be more explicit in detailing the assumptions the cookbook makes about how your app works or how you subsequently deploy it.  
> Agreed. And there's the fact that there's one cookbook on top of the other (application\_ruby uses application, but you first need to understand how application works before you even try to begin understanding how application\_\* does, which is not only a mess in itself, but is not clearly stated anywhere I could see either). There should be some sort of a cookbook manual for these cases -- a cookbook cookbook? 🙂
> 
> > Thanks for all the pointers, I believe I have enough to get going for now. 🙂
> 
> Glad to be of help!
> 
> Mat  
> Yeah, thanks again. I haven't yet gotten to the state where I can say that this will definitely work, but there's nothing pointing me to the contrary atm. I still neet to get the pg gem to compile when bundler runs, but I'm going to open a separate thread for that. 🙂

Cheers!

- cassiano

---

<div class="post-metadata">

**Author:** ![Mathieu\_Martin](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/mathieu_martin/32/60_2.png) [@Mathieu\_Martin](https://discourse.chef.io/u/Mathieu_Martin)\
**Post date:** [May 11, 2013, 2:51pm UTC](https://discourse.chef.io/t/application-ruby-cookbook-and-rbenv/3932/10 "2013-05-11T14:51:00Z")

</div>

Ah, look at teohm's databox cb. Handles both pg and mysql 🙂

On Saturday, May 11, 2013, Cassiano Leal wrote:

> On Saturday, May 11, 2013 at 02:30, Mathieu Martin wrote:
> 
> On Fri, May 10, 2013 at 10:19 PM, Cassiano Leal \<[cassianoleal@gmail.com](mailto:cassianoleal@gmail.com)\<javascript:\_e({}, 'cvml', 'cassianoleal@gmail.com');\>
> 
> > wrote:
> 
> It still eludes me why it's so difficult to reproduce my current setup in  
> Chef, though.
> 
> I do think some of those cookbooks (e.g. application\_ruby, deploy, nginx  
> w/ Passenger) don't do enough handholding to help newcomers understand how  
> they should be used. I don't use them.
> 
> The attributes are all laid out just fine, but I think they could be more  
> explicit in detailing the assumptions the cookbook makes about how your app  
> works or how you subsequently deploy it.
> 
> Agreed. And there's the fact that there's one cookbook on top of the other  
> (application\_ruby uses application, but you first need to understand how  
> application works before you even try to begin understanding how  
> application\_\* does, which is not only a mess in itself, but is not clearly  
> stated anywhere I could see either). There should be some sort of a  
> cookbook manual for these cases -- a cookbook cookbook? 🙂
> 
> Thanks for all the pointers, I believe I have enough to get going for now.  
> 🙂
> 
> Glad to be of help!
> 
> Mat
> 
> Yeah, thanks again. I haven't yet gotten to the state where I can say  
> that this will definitely work, but there's nothing pointing me to the  
> contrary atm. I still neet to get the pg gem to compile when bundler runs,  
> but I'm going to open a separate thread for that. 🙂
> 
> Cheers!
> 
> - cassiano

--

--

I'm the founder of Rock Solid Ops Inc, a web consultancy.

My main fields of expertise are Ruby on Rails web development, DevOps and a  
bit of mobile. If you need help scaling, understanding, securing or  
managing your web infrastructure (Rails or not), get in touch!

Connect with me and read testimonials on my  
LinkedIn[http://ca.linkedin.com/in/mathieumartin/](http://ca.linkedin.com/in/mathieumartin/),  
follow me on twitter @webmat [http://twitter.com/webmat](http://twitter.com/webmat), or check out my  
blog at [programblings.com](http://programblings.com)[http://www.programblings.com?utm\_source=email+signature](http://www.programblings.com?utm_source=email+signature)  
.

If you're a tech person, the following may make sense to you.

I'm the author of  
git\_remote\_branch[https://rubygems.org/gems/git\_remote\_branch](https://rubygems.org/gems/git_remote_branch).  
A tool that's been helping common mortals like me share git branches for 5  
years. Downloaded 50 000 times.

I've also contributed to some of the popular libraries in the Rails, jQuery  
and PhoneGap ecosystems:

paperclip, active\_admin, jquery-ujs, jquery-rails, kaminari, AssetSync,  
phonegap-plugin-facebook-connect, shoulda, woulda, jeweler.

If you visit them on GitHub, you'll see my face in the "Contributors"  
section 🙂

---

<div class="post-metadata">

**Author:** ![Cassiano\_Leal](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/cassiano_leal/32/86_2.png) [@Cassiano\_Leal](https://discourse.chef.io/u/Cassiano_Leal)\
**Post date:** [May 12, 2013, 7:24pm UTC](https://discourse.chef.io/t/application-ruby-cookbook-and-rbenv/3932/11 "2013-05-12T19:24:07Z")

</div>

I don't see how that would help, unfortunately… My problem seems to be that bundler is running on omnibus's Ruby (not even on the system Ruby as I had original thought). I uninstalled all Ruby packages from the system, leaving it with only omnibus and one rbenv-managed Ruby. If I SSH into the machine and run bundler, it works. When Chef runs bundler during the deployment, it fails.

And I just found this line:  
--ruby=/opt/chef/embedded/bin/ruby

This is one of the options passed by bundler to the gem command.

It just seems like I went out of the frying pan and into the fire. I can easily avoid the mod\_rails compilation problem by running passenger standalone as you suggested, but that doesn't solve the bigger problem of the whole thing running outside of the rbenv Ruby.

Cheers!

- cassiano

On Saturday, May 11, 2013 at 11:51, Mathieu Martin wrote:

> Ah, look at teohm's databox cb. Handles both pg and mysql 🙂
> 
> On Saturday, May 11, 2013, Cassiano Leal wrote:
> 
> > On Saturday, May 11, 2013 at 02:30, Mathieu Martin wrote:
> > 
> > > On Fri, May 10, 2013 at 10:19 PM, Cassiano Leal \<[cassianoleal@gmail.com](mailto:cassianoleal@gmail.com) (javascript:\_e({}, 'cvml', 'cassianoleal@gmail.com');)\> wrote:
> > > 
> > > > It still eludes me why it's so difficult to reproduce my current setup in Chef, though.
> > > 
> > > I do think some of those cookbooks (e.g. application\_ruby, deploy, nginx w/ Passenger) don't do enough handholding to help newcomers understand how they should be used. I don't use them.
> > > 
> > > The attributes are all laid out just fine, but I think they could be more explicit in detailing the assumptions the cookbook makes about how your app works or how you subsequently deploy it.  
> > > Agreed. And there's the fact that there's one cookbook on top of the other (application\_ruby uses application, but you first need to understand how application works before you even try to begin understanding how application\_\* does, which is not only a mess in itself, but is not clearly stated anywhere I could see either). There should be some sort of a cookbook manual for these cases -- a cookbook cookbook? 🙂
> > > 
> > > > Thanks for all the pointers, I believe I have enough to get going for now. 🙂
> > > 
> > > Glad to be of help!
> > > 
> > > Mat  
> > > Yeah, thanks again. I haven't yet gotten to the state where I can say that this will definitely work, but there's nothing pointing me to the contrary atm. I still neet to get the pg gem to compile when bundler runs, but I'm going to open a separate thread for that. 🙂
> > 
> > Cheers!
> > 
> > - cassiano
> 
> --
> 
> --
> 
> I'm the founder of Rock Solid Ops Inc, a web consultancy.
> 
> My main fields of expertise are Ruby on Rails web development, DevOps and a bit of mobile. If you need help scaling, understanding, securing or managing your web infrastructure (Rails or not), get in touch!
> 
> Connect with me and read testimonials on my LinkedIn ([Mathieu Martin - Jane Technologies, Inc. | LinkedIn](http://ca.linkedin.com/in/mathieumartin/)), follow me on twitter @webmat ([http://twitter.com/webmat](http://twitter.com/webmat)), or check out my blog at [programblings.com](http://programblings.com) ([Programblings](http://www.programblings.com?utm_source=email+signature)).
> 
> If you're a tech person, the following may make sense to you.
> 
> I'm the author of git\_remote\_branch ([git\_remote\_branch | RubyGems.org | your community gem host](https://rubygems.org/gems/git_remote_branch)). A tool that's been helping common mortals like me share git branches for 5 years. Downloaded 50 000 times.
> 
> I've also contributed to some of the popular libraries in the Rails, jQuery and PhoneGap ecosystems:
> 
> paperclip, active\_admin, jquery-ujs, jquery-rails, kaminari, AssetSync, phonegap-plugin-facebook-connect, shoulda, woulda, jeweler.
> 
> If you visit them on GitHub, you'll see my face in the "Contributors" section 🙂
