Skip to content

Instantly share code, notes, and snippets.

@simonrobson
Last active December 19, 2015 19:38
Show Gist options
  • Save simonrobson/6007369 to your computer and use it in GitHub Desktop.
Save simonrobson/6007369 to your computer and use it in GitHub Desktop.
Workaround for Ominbus-installed chef not working with rvm

As described here, ominbus-installed chef doesn't play well with rvm. This script automates wrapping the chef binary symlinks in /usr/bin so they work again. Tested on OSX.

#!/bin/bash
CHEF_DIR="/opt/chef"
PREFIX="/usr"
WRAPPER=$PREFIX/bin/chef-wrapper
cat > $WRAPPER <<ENDS
#!/bin/bash
unset GEM_HOME
unset GEM_PATH
ENDS
echo exec $CHEF_DIR/bin/\$\{0/*\\/\/\} \$* >> $WRAPPER
chmod +x $WRAPPER
ln -sf $WRAPPER $PREFIX/bin/chef-client
ln -sf $WRAPPER $PREFIX/bin/chef-solo
ln -sf $WRAPPER $PREFIX/bin/chef-apply
ln -sf $WRAPPER $PREFIX/bin/chef-shell
ln -sf $WRAPPER $PREFIX/bin/knife
ln -sf $WRAPPER $PREFIX/bin/shef
ln -sf $WRAPPER $PREFIX/bin/ohai
#!/bin/bash
unset GEM_HOME
unset GEM_PATH
exec /opt/chef/bin/${0/*\//} $*
(straight from linked issue, without the quoting :) Thanks Larry Gilbert
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment