Skip to content

Instantly share code, notes, and snippets.

@gildas
Created April 21, 2015 07:35
Show Gist options
  • Save gildas/35adc856cfa949d2e085 to your computer and use it in GitHub Desktop.
Save gildas/35adc856cfa949d2e085 to your computer and use it in GitHub Desktop.
use real vagrant outside of gemset in shim
#!/usr/bin/env bash
set -e
[ -n "$RBENV_DEBUG" ] && set -x
program="${0##*/}"
if [ "$program" = "ruby" ]; then
for arg; do
case "$arg" in
-e* | -- ) break ;;
*/* )
if [ -f "$arg" ]; then
export RBENV_DIR="${arg%/*}"
break
fi
;;
esac
done
fi
# if vagrant is part of a gemset and we are not in any subfolder, use the standard vagrant
ruby_version="$(rbenv version)"
if [[ -z "$(rbenv gemset list | grep "${ruby_version%% *}")" ]]; then
/opt/vagrant/bin/vagrant "$@"
else
export RBENV_ROOT="/Users/gildas/.config/rbenv"
exec "/usr/local/Cellar/rbenv/0.4.0/libexec/rbenv" exec "$program" "$@"
fi
@gildas
Copy link
Author

gildas commented Apr 21, 2015

Not perfect yet:

  • Does not deal with same rbenv version but outside of the gemset.
  • Uses hardcoded location for vagrant.
    That's a start shall we say.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment