[chef] Re: Re: omnibus-chef 11 ruby conflicts


Chronological Thread 
  • From: Morgan Blackthorne < >
  • To: " " < >
  • Subject: [chef] Re: Re: omnibus-chef 11 ruby conflicts
  • Date: Wed, 29 May 2013 21:04:02 -0700

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


On Wed, May 29, 2013 at 8:37 PM, Benjamin Bytheway < " target="_blank"> > 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:


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:


Which pulls in the omnibus-software scripts.

Good luck!

Ben Bytheway


On Wed, May 29, 2013 at 8:50 PM, Andrew Hollingsworth < " target="_blank"> > 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 :

  /opt/chef/embedded/bin/chef-apply
  /opt/chef/embedded/bin/chef-client
  /opt/chef/embedded/bin/chef-shell
  /opt/chef/embedded/bin/chef-solo
  /opt/chef/embedded/bin/erubis
  /opt/chef/embedded/bin/knife
  /opt/chef/embedded/bin/ohai
  /opt/chef/embedded/bin/restclient
  /opt/chef/embedded/bin/shef

- 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/<cmd> 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 :

  /opt/chef/bin/chef-apply -> ../embedded/bin/chef-cmd-wrapper
  /opt/chef/bin/chef-client -> ../embedded/bin/chef-cmd-wrapper
  /opt/chef/bin/chef-shell -> ../embedded/bin/chef-cmd-wrapper
  /opt/chef/bin/chef-solo -> ../embedded/bin/chef-cmd-wrapper
  /opt/chef/bin/erubis -> ../embedded/bin/chef-cmd-wrapper
  /opt/chef/bin/knife -> ../embedded/bin/chef-cmd-wrapper
  /opt/chef/bin/ohai -> ../embedded/bin/chef-cmd-wrapper
  /opt/chef/bin/restclient -> ../embedded/bin/chef-cmd-wrapper
  /opt/chef/bin/shef -> ../embedded/bin/chef-cmd-wrapper

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

Cheers,

adh
--
Andrew Hollingsworth

Website : http://www.techopsguru.com
Twitter : twitter.com/techopsguru





Archive powered by MHonArc 2.6.16.

§