mirror of
https://github.com/pyenv/pyenv.git
synced 2025-11-13 13:53:53 -05:00
Support GEM_HOME, add limited support for user-installed gems (#1436)
The rehash process will now discover executables in additional locations: - `~/.gem/ruby/<version>/bin/*` - `$GEM_HOME/bin` The `rbenv which` (and thus `rbenv exec`) command will also search these locations when looking up a command. This enables shims to dispatch calls to executables added by `gem install --user-install`. Note that this support is limited: - It will only work with C Ruby, as it's difficult to guess the `~/.gem/<engine>/<version>` directory for other Rubies without actually loading Ruby; - It will only work for RBENV_VERSION values in the format `X.Y.Z` and not "system".
This commit is contained in:
@@ -104,6 +104,15 @@ list_executable_names() {
|
||||
echo "${file##*/}"
|
||||
done
|
||||
done
|
||||
# list user-install'ed executables
|
||||
for file in ~/.gem/ruby/*/bin/*; do
|
||||
echo "${file##*/}"
|
||||
done
|
||||
if [ -n "$GEM_HOME" ]; then
|
||||
for file in "$GEM_HOME"/bin/*; do
|
||||
echo "${file##*/}"
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
# The basename of each argument passed to `make_shims` will be
|
||||
|
||||
@@ -41,6 +41,17 @@ if [ "$RBENV_VERSION" = "system" ]; then
|
||||
RBENV_COMMAND_PATH="$(command -v "$RBENV_COMMAND" || true)"
|
||||
else
|
||||
RBENV_COMMAND_PATH="${RBENV_ROOT}/versions/${RBENV_VERSION}/bin/${RBENV_COMMAND}"
|
||||
if [ ! -x "$RBENV_COMMAND_PATH" ]; then
|
||||
# discover user-install'ed gem executables
|
||||
if [ -n "$GEM_HOME" ]; then
|
||||
user_install_path="${GEM_HOME}/bin/${RBENV_COMMAND}"
|
||||
else
|
||||
# FIXME: guessing this path is very fragile and works only for C Ruby
|
||||
user_install_path="${HOME}/.gem/ruby/${RBENV_VERSION%.*}.0/bin/${RBENV_COMMAND}"
|
||||
fi
|
||||
[ -x "$user_install_path" ] && RBENV_COMMAND_PATH="$user_install_path"
|
||||
unset user_install_path
|
||||
fi
|
||||
fi
|
||||
|
||||
OLDIFS="$IFS"
|
||||
|
||||
Reference in New Issue
Block a user