From 410e05bf8ca09d736985806e9849e675635a4230 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Fri, 7 Oct 2022 12:56:54 +0200 Subject: [PATCH] Revert support for user-installed gems (#1443) --- libexec/rbenv-rehash | 4 ---- libexec/rbenv-which | 15 ++++----------- test/rehash.bats | 17 ++++++----------- test/which.bats | 11 +++++++++-- 4 files changed, 19 insertions(+), 28 deletions(-) diff --git a/libexec/rbenv-rehash b/libexec/rbenv-rehash index 56b8a56..47a5d29 100755 --- a/libexec/rbenv-rehash +++ b/libexec/rbenv-rehash @@ -104,10 +104,6 @@ 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##*/}" diff --git a/libexec/rbenv-which b/libexec/rbenv-which index f4d0b8f..80f0df8 100755 --- a/libexec/rbenv-which +++ b/libexec/rbenv-which @@ -41,17 +41,10 @@ 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 + +if [[ ! -x "$RBENV_COMMAND_PATH" && -n "$GEM_HOME" && -x "${GEM_HOME}/bin/${RBENV_COMMAND}" ]]; then + RBENV_COMMAND_PATH="${GEM_HOME}/bin/${RBENV_COMMAND}" fi OLDIFS="$IFS" diff --git a/test/rehash.bats b/test/rehash.bats index e0c6627..ab7645f 100755 --- a/test/rehash.bats +++ b/test/rehash.bats @@ -105,22 +105,17 @@ ruby OUT } -@test "user-install" { - create_executable "${HOME}/.gem/ruby/3.0.0/bin/lolcat" +@test "no shims for user-installed gems" { + create_executable "2.7.5" "ruby" + create_executable "3.1.2" "ruby" + create_executable "${HOME}/.gem/ruby/2.7.0/bin/lolcat" create_executable "${HOME}/.gem/ruby/3.1.0/bin/pinecone" - assert [ ! -e "${RBENV_ROOT}/shims/lolcat" ] - assert [ ! -e "${RBENV_ROOT}/shims/pinecone" ] - run rbenv-rehash assert_success "" - run ls "${RBENV_ROOT}/shims" - assert_success - assert_output <