From e2173df4aa91c8d365ca1596fb857fcac9fdd787 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Wed, 15 Oct 2014 01:36:20 +0200 Subject: [PATCH] Revert "Don't duplicate shims in PATH" Too many of our users have a shell initialization set up that inadvertently duplicates some or most of the entries in their PATH, bringing the system paths again in front of rbenv's shims. If this was a nested shell (a typical scenario when starting up tmux), `rbenv init` would get eval'd again but this time, shims won't get added to the front of the PATH and would only stay and the end of the path, effectively rendering them useless. I tried to argue that this is a user problem rather than rbenv's, but I can't fix everybody shell init when they report bugs. Instead, let's revert to simpler times in rbenv where we just roll along with the duplication and don't ask any questions. This reverts commit 03fa148e814d50aba8012dc94b866213a00ea8a9. Fixes #369 --- libexec/rbenv-init | 13 ++----------- libexec/rbenv-realpath.dylib | Bin 0 -> 8672 bytes test/init.bats | 4 ++-- 3 files changed, 4 insertions(+), 13 deletions(-) create mode 100755 libexec/rbenv-realpath.dylib diff --git a/libexec/rbenv-init b/libexec/rbenv-init index 5f9079a..fbffb85 100755 --- a/libexec/rbenv-init +++ b/libexec/rbenv-init @@ -92,22 +92,13 @@ fi mkdir -p "${RBENV_ROOT}/"{shims,versions} -if [[ ":${PATH}:" != *:"${RBENV_ROOT}/shims":* ]]; then - case "$shell" in - fish ) - echo "setenv PATH '${RBENV_ROOT}/shims' \$PATH" - ;; - * ) - echo 'export PATH="'${RBENV_ROOT}'/shims:${PATH}"' - ;; - esac -fi - case "$shell" in fish ) + echo "setenv PATH '${RBENV_ROOT}/shims' \$PATH" echo "setenv RBENV_SHELL $shell" ;; * ) + echo 'export PATH="'${RBENV_ROOT}'/shims:${PATH}"' echo "export RBENV_SHELL=$shell" ;; esac diff --git a/libexec/rbenv-realpath.dylib b/libexec/rbenv-realpath.dylib new file mode 100755 index 0000000000000000000000000000000000000000..c42aca38256af4e3c9531371636e35fb94e1bfe3 GIT binary patch literal 8672 zcmeHNL2MgE6#Z@rN!vgi)I*?vrd3h}N;gIzQA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K+djJ3c literal 0 HcmV?d00001 diff --git a/test/init.bats b/test/init.bats index aa50f09..78a762f 100644 --- a/test/init.bats +++ b/test/init.bats @@ -64,11 +64,11 @@ load test_helper assert_line 0 "setenv PATH '${RBENV_ROOT}/shims' \$PATH" } -@test "doesn't add shims to PATH more than once" { +@test "can add shims to PATH more than once" { export PATH="${RBENV_ROOT}/shims:$PATH" run rbenv-init - bash assert_success - refute_line 'export PATH="'${RBENV_ROOT}'/shims:${PATH}"' + assert_line 0 'export PATH="'${RBENV_ROOT}'/shims:${PATH}"' } @test "doesn't add shims to PATH more than once (fish)" {