Skip to content

Instantly share code, notes, and snippets.

@dstrelau
Created October 8, 2013 22:18
Show Gist options
  • Save dstrelau/6892770 to your computer and use it in GitHub Desktop.
Save dstrelau/6892770 to your computer and use it in GitHub Desktop.
require 'formula'
class Rbenv < Formula
homepage 'https://github.com/sstephenson/rbenv'
url 'https://github.com/sstephenson/rbenv/archive/v0.4.0.tar.gz'
sha1 '825ceec55805b8bb80a6d6003fd3cef824d7ff14'
head 'https://github.com/sstephenson/rbenv.git'
def install
inreplace 'libexec/rbenv', '/usr/local', HOMEBREW_PREFIX
prefix.install Dir['*']
end
def caveats; <<-EOS.undent
To use Homebrew's directories rather than ~/.rbenv add to your profile:
export RBENV_ROOT=#{var}/rbenv
To enable shims and autocompletion add to your profile:
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
EOS
end
def patches
# rbx-2.0.0 support
DATA
end
end
__END__
diff --git a/libexec/rbenv-rehash b/libexec/rbenv-rehash
index 5ec195e..2b6f46d 100755
--- a/libexec/rbenv-rehash
+++ b/libexec/rbenv-rehash
@@ -138,7 +138,7 @@ shopt -s nullglob
# executables.
create_prototype_shim
remove_outdated_shims
-make_shims ../versions/*/bin/*
+make_shims ../versions/*/{,gems/}bin/*
# Restore the previous working directory.
cd "$OLDPWD"
diff --git a/libexec/rbenv-which b/libexec/rbenv-which
index 5d73673..b421a49 100755
--- a/libexec/rbenv-which
+++ b/libexec/rbenv-which
@@ -60,7 +60,11 @@ if [ "$RBENV_VERSION" = "system" ]; then
PATH="$(remove_from_path "${RBENV_ROOT}/shims")"
RBENV_COMMAND_PATH="$(command -v "$RBENV_COMMAND" || true)"
else
- RBENV_COMMAND_PATH="${RBENV_ROOT}/versions/${RBENV_VERSION}/bin/${RBENV_COMMAND}"
+ version_prefix="${RBENV_ROOT}/versions/${RBENV_VERSION}"
+ RBENV_COMMAND_PATH="${version_prefix}/gems/bin/${RBENV_COMMAND}"
+ if [ ! -x "$RBENV_COMMAND_PATH" ]; then
+ RBENV_COMMAND_PATH="${version_prefix}/bin/${RBENV_COMMAND}"
+ fi
fi
OLDIFS="$IFS"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment