Skip to content

Commit

Permalink
Avoid an infinite loop when ruby version is "system"
Browse files Browse the repository at this point in the history
The loop was caused by rbenv-gemset's rbenv-which hook, which was
called when rbenv-which was invoked. rbenv-gemset's hook then invoked
rbenv-prefix, which (when version is "system") in turn invokes rbenv-which,
and the cycle continued.

This solution gives a hard default directory for system gemsets.
  • Loading branch information
jamis committed Sep 21, 2011
1 parent eb57377 commit d3b11d0
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions bin/rbenv-gemset
Expand Up @@ -82,6 +82,8 @@ case "$1" in
RBENV_PLUGIN_ROOT="${HOME}/.rbenv/rbenv.d"
fi

RBENV_GEMSET_SYSTEM_ROOT="/usr/local/share/ruby-gemsets"

mkdir -p "${RBENV_PLUGIN_ROOT}/exec"
mkdir -p "${RBENV_PLUGIN_ROOT}/rehash"
mkdir -p "${RBENV_PLUGIN_ROOT}/util"
Expand Down Expand Up @@ -118,7 +120,12 @@ source "${RBENV_PLUGIN_ROOT}/util/gemset.bash"
unset GEM_HOME GEM_PATH
RBENV_GEMSET_ROOT="\$(rbenv prefix)/gemsets"
if [ "\$(rbenv-version-name)" = "system" ]; then
RBENV_GEMSET_ROOT="$RBENV_GEMSET_SYSTEM_ROOT"
else
RBENV_GEMSET_ROOT="\$(rbenv prefix)/gemsets"
fi
for gemset in \$(active_gemsets)
do
path="\${RBENV_GEMSET_ROOT}/\${gemset}"
Expand All @@ -138,7 +145,12 @@ PLUGIN
cat > "${RBENV_PLUGIN_ROOT}/which/gemset.bash" <<-PLUGIN
source "${RBENV_PLUGIN_ROOT}/util/gemset.bash"
RBENV_GEMSET_ROOT="\$(rbenv prefix)/gemsets"
if [ "\$(rbenv-version-name)" = "system" ]; then
RBENV_GEMSET_ROOT="$RBENV_GEMSET_SYSTEM_ROOT"
else
RBENV_GEMSET_ROOT="\$(rbenv prefix)/gemsets"
fi
if [ ! -x "\$RBENV_COMMAND_PATH" ]; then
for gemset in \$(active_gemsets); do
command="\${RBENV_GEMSET_ROOT}/\${gemset}/bin/\$RBENV_COMMAND"
Expand Down

0 comments on commit d3b11d0

Please sign in to comment.