Merge pull request #919 from yyuu/system-in-bin

Add a workaround system executable in `/bin`
This commit is contained in:
Mislav Marohnić 2016-08-03 03:58:31 -09:00 committed by GitHub
commit 0c7224af95
2 changed files with 14 additions and 1 deletions

View file

@ -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

View file

@ -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" <<OUT
#!/bin/sh
echo /bin/ruby
OUT
chmod +x "${BATS_TEST_DIRNAME}/libexec/rbenv-which"
RBENV_VERSION="system" run rbenv-prefix
assert_success "/"
rm -f "${BATS_TEST_DIRNAME}/libexec/rbenv-which"
}
@test "prefix for invalid system" {
PATH="$(path_without ruby)" run rbenv-prefix system
assert_failure "rbenv: system version not found in PATH"