diff --git a/libexec/rbenv-prefix b/libexec/rbenv-prefix index 5376cf5..e65be83 100755 --- a/libexec/rbenv-prefix +++ b/libexec/rbenv-prefix @@ -24,7 +24,8 @@ fi if [ "$RBENV_VERSION" = "system" ]; then if RUBY_PATH="$(rbenv-which ruby 2>/dev/null)"; then RUBY_PATH="${RUBY_PATH%/*}" - echo "${RUBY_PATH%/bin}" + RBENV_PREFIX_PATH="${RUBY_PATH%/bin}" + echo "${RBENV_PREFIX_PATH:-/}" exit else echo "rbenv: system version not found in PATH" >&2 diff --git a/test/prefix.bats b/test/prefix.bats index 3fb9408..bdee6f0 100644 --- a/test/prefix.bats +++ b/test/prefix.bats @@ -24,6 +24,18 @@ load test_helper assert_success "$RBENV_TEST_DIR" } +@test "prefix for system in /" { + mkdir -p "${BATS_TEST_DIRNAME}/libexec" + cat >"${BATS_TEST_DIRNAME}/libexec/rbenv-which" <