# Omnibus-chef 11 ruby conflicts

**URL:** <https://discourse.chef.io/t/omnibus-chef-11-ruby-conflicts/4035>\
**Category:** Chef Infra (archive)\
**Created:** [May 30, 2013, 2:50am UTC](https://discourse.chef.io/t/omnibus-chef-11-ruby-conflicts/4035 "2013-05-30T02:50:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrew\_Hollingsworth](https://avatars.discourse-cdn.com/v4/letter/a/f05b48/32.png) [@Andrew\_Hollingsworth](https://discourse.chef.io/u/Andrew_Hollingsworth)\
**Post date:** [May 30, 2013, 2:50am UTC](https://discourse.chef.io/t/omnibus-chef-11-ruby-conflicts/4035/1 "2013-05-30T02:50:20Z")

</div>

Hi all,

Those of us using RVM or other local ruby installs may have come across a  
problem when using omnibus-chef 11. The issue is that the wrong gem path  
can be pulled in from the local ruby and gem path and therefore chef  
commands fail.

Vagrant gets around this by wrapping the vagrant command in a shell script  
which sets the correct environment variables for ruby and gem paths before  
calling the command directly thus ensuring the correct gem paths are set up  
and embedded ruby is used.

This could easily be done in chef as shown below. My question is where can  
I submit this as a contributed change? Comments on the methodology are  
welcome.

I’ve made the following changes locally and tested them but cannot find  
where in the code to put the changes to submit a pull request :

- Install rubygems to /opt/chef/embedded/bin instead of /opt/chef/bin using  
rubygems as it is done now resulting in :

- A wrapper script for chef commands  
/opt/chef/embedded/bin/chef-cmd-wrapper as all the rubygem installed  
commands work the same way :

This wrapper sets the GEM\_HOME and GEM\_PATH and runs the correct command in  
/opt/chef/embedded/bin/ above:

#!/usr/bin/env bash  
SOURCE="{BASH\_SOURCE[0]}" DIR=(dirname SOURCE) EMBEDDED\_DIR="{DIR}/…/embedded"

# Export gem paths so that we use the isolated gems.

export GEM\_HOME="{EMBEDDED\_DIR}/lib/ruby/gems/1.9.1" export GEM\_PATH={GEM\_HOME}  
export CHEF\_CMD=$(basename $SOURCE)

EMBEDDED\_DIR/bin/{CHEF\_CMD} @ exit ?

The GEM\_HOME could be set to the latest path gem path as part of the  
install. Any other variables (GEMRC?) could be set here also.

- Only symbolic links exist in /opt/chef/bin pointing at the wrapper  
/opt/ohef/embedded/bin/chef-cmd-wrapper. Links are created relative rather  
than absolute in case the root directory is different :

Thoughts and comments welcome. Or maybe the issue is already dealt with…

Cheers,

## adh

Andrew Hollingsworth

Website : [http://www.techopsguru.com](http://www.techopsguru.com)  
Twitter : [twitter.com/techopsguru-](http://twitter.com/techopsguru-)

---

<div class="post-metadata">

**Author:** ![bytheway](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/bytheway/32/123_2.png) [@bytheway](https://discourse.chef.io/u/bytheway)\
**Post date:** [May 30, 2013, 3:37am UTC](https://discourse.chef.io/t/omnibus-chef-11-ruby-conflicts/4035/2 "2013-05-30T03:37:24Z")

</div>

I like this approach, I've fought with this myself, but usually end up just  
installing the chef gems instead of the omnibus.

I think the right place to change how things work is in the  
omnibus-software project, in the chef build script:

> <https://github.com/chef/omnibus-software/blob/main/config/software/chef.rb>

Looks like the gem install is being hardcoded with a "-n  
#{install\_dir}/bin" when it should be allowed to go into embedded/bin,  
which would be the first step.

The project that has the bits for actually building and packaging chef is:

> **[GitHub - chef-boneyard/omnibus-chef: Omnibus packaging for Chef](https://github.com/chef-boneyard/omnibus-chef)**
>
> Omnibus packaging for Chef. Contribute to chef-boneyard/omnibus-chef development by creating an account on GitHub.

Which pulls in the omnibus-software scripts.

Good luck!

Ben Bytheway

On Wed, May 29, 2013 at 8:50 PM, Andrew Hollingsworth  
[adh@techopsguru.com](mailto:adh@techopsguru.com)wrote:

> Hi all,
> 
> Those of us using RVM or other local ruby installs may have come across a  
> problem when using omnibus-chef 11. The issue is that the wrong gem path  
> can be pulled in from the local ruby and gem path and therefore chef  
> commands fail.
> 
> Vagrant gets around this by wrapping the vagrant command in a shell script  
> which sets the correct environment variables for ruby and gem paths before  
> calling the command directly thus ensuring the correct gem paths are set up  
> and embedded ruby is used.
> 
> This could easily be done in chef as shown below. My question is where can  
> I submit this as a contributed change? Comments on the methodology are  
> welcome.
> 
> I've made the following changes locally and tested them but cannot find  
> where in the code to put the changes to submit a pull request :
> 
> - Install rubygems to /opt/chef/embedded/bin instead of /opt/chef/bin  
> using rubygems as it is done now resulting in :
> 
> - A wrapper script for chef commands  
> /opt/chef/embedded/bin/chef-cmd-wrapper as all the rubygem installed  
> commands work the same way :
> 
> This wrapper sets the GEM\_HOME and GEM\_PATH and runs the correct command  
> in /opt/chef/embedded/bin/ above:
> 
> #!/usr/bin/env bash  
> SOURCE="${BASH\_SOURCE[0]}"  
> DIR=$(dirname $SOURCE)  
> EMBEDDED\_DIR="${DIR}/../embedded"
> 
> # Export gem paths so that we use the isolated gems.
> 
> export GEM\_HOME="${EMBEDDED\_DIR}/lib/ruby/gems/1.9.1"  
> export GEM\_PATH=${GEM\_HOME}  
> export CHEF\_CMD=$(basename $SOURCE)
> 
> $EMBEDDED\_DIR/bin/${CHEF\_CMD} $@  
> exit $?
> 
> The GEM\_HOME could be set to the latest path gem path as part of the  
> install. Any other variables (GEMRC?) could be set here also.
> 
> - Only symbolic links exist in /opt/chef/bin pointing at the wrapper  
> /opt/ohef/embedded/bin/chef-cmd-wrapper. Links are created relative rather  
> than absolute in case the root directory is different :
> 
> Thoughts and comments welcome. Or maybe the issue is already dealt  
> with....
> 
> Cheers,
> 
> ## adh
> 
> Andrew Hollingsworth
> 
> Website : [http://www.techopsguru.com](http://www.techopsguru.com)  
> Twitter : [twitter.com/techopsguru-](http://twitter.com/techopsguru-)

---

<div class="post-metadata">

**Author:** ![Morgan\_Blackthorne](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/morgan_blackthorne/32/100_2.png) [@Morgan\_Blackthorne](https://discourse.chef.io/u/Morgan_Blackthorne)\
**Post date:** [May 30, 2013, 4:04am UTC](https://discourse.chef.io/t/omnibus-chef-11-ruby-conflicts/4035/3 "2013-05-30T04:04:02Z")

</div>

Yeah, I ended up de-installing RVM and just putting /opt/chef/embedded/bin  
very high in my $PATH to work around this exact issue. (Which was only an  
option because the only real Ruby work I do is Chef-related.) I originally  
tried writing wrapper scripts for each command to work around it, but that  
ended up being unwieldy and often broke due to dependencies.

--  
~_~ StormeRider ~_~

"Every world needs its heroes [...] They inspire us to be better than we  
are. And they protect from the darkness that's just around the corner."

(from Smallville Season 6x1: "Zod")

On why I hate the phrase "that's so lame"... [http://bit.ly/Ps3uSS](http://bit.ly/Ps3uSS)

On Wed, May 29, 2013 at 8:37 PM, Benjamin Bytheway [bbytheway@gmail.com](mailto:bbytheway@gmail.com)wrote:

> I like this approach, I've fought with this myself, but usually end up  
> just installing the chef gems instead of the omnibus.
> 
> I think the right place to change how things work is in the  
> omnibus-software project, in the chef build script:
> 
> [omnibus-software/config/software/chef.rb at main · chef/omnibus-software · GitHub](https://github.com/opscode/omnibus-software/blob/master/config/software/chef.rb)
> 
> Looks like the gem install is being hardcoded with a "-n  
> #{install\_dir}/bin" when it should be allowed to go into embedded/bin,  
> which would be the first step.
> 
> The project that has the bits for actually building and packaging chef is:
> 
> [GitHub - chef-boneyard/omnibus-chef: Omnibus packaging for Chef](https://github.com/opscode/omnibus-chef)
> 
> Which pulls in the omnibus-software scripts.
> 
> Good luck!
> 
> Ben Bytheway
> 
> On Wed, May 29, 2013 at 8:50 PM, Andrew Hollingsworth \<[adh@techopsguru.com](mailto:adh@techopsguru.com)
> 
> > wrote:
> 
> > Hi all,
> > 
> > Those of us using RVM or other local ruby installs may have come across a  
> > problem when using omnibus-chef 11. The issue is that the wrong gem path  
> > can be pulled in from the local ruby and gem path and therefore chef  
> > commands fail.
> > 
> > Vagrant gets around this by wrapping the vagrant command in a shell  
> > script which sets the correct environment variables for ruby and gem paths  
> > before calling the command directly thus ensuring the correct gem paths are  
> > set up and embedded ruby is used.
> > 
> > This could easily be done in chef as shown below. My question is where  
> > can I submit this as a contributed change? Comments on the methodology are  
> > welcome.
> > 
> > I've made the following changes locally and tested them but cannot find  
> > where in the code to put the changes to submit a pull request :
> > 
> > - Install rubygems to /opt/chef/embedded/bin instead of /opt/chef/bin  
> > using rubygems as it is done now resulting in :
> > 
> > - A wrapper script for chef commands  
> > /opt/chef/embedded/bin/chef-cmd-wrapper as all the rubygem installed  
> > commands work the same way :
> > 
> > This wrapper sets the GEM\_HOME and GEM\_PATH and runs the correct command  
> > in /opt/chef/embedded/bin/ above:
> > 
> > #!/usr/bin/env bash  
> > SOURCE="${BASH\_SOURCE[0]}"  
> > DIR=$(dirname $SOURCE)  
> > EMBEDDED\_DIR="${DIR}/../embedded"
> > 
> > # Export gem paths so that we use the isolated gems.
> > 
> > export GEM\_HOME="${EMBEDDED\_DIR}/lib/ruby/gems/1.9.1"  
> > export GEM\_PATH=${GEM\_HOME}  
> > export CHEF\_CMD=$(basename $SOURCE)
> > 
> > $EMBEDDED\_DIR/bin/${CHEF\_CMD} $@  
> > exit $?
> > 
> > The GEM\_HOME could be set to the latest path gem path as part of the  
> > install. Any other variables (GEMRC?) could be set here also.
> > 
> > - Only symbolic links exist in /opt/chef/bin pointing at the wrapper  
> > /opt/ohef/embedded/bin/chef-cmd-wrapper. Links are created relative rather  
> > than absolute in case the root directory is different :
> > 
> > Thoughts and comments welcome. Or maybe the issue is already dealt  
> > with....
> > 
> > Cheers,
> > 
> > ## adh
> > 
> > Andrew Hollingsworth
> > 
> > Website : [http://www.techopsguru.com](http://www.techopsguru.com)  
> > Twitter : [twitter.com/techopsguru-](http://twitter.com/techopsguru-)
