Browse Source

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

Add a workaround system executable in `/bin`
pull/669/head
Mislav Marohnić 10 years ago
committed by GitHub
parent
commit
0c7224af95
2 changed files with 14 additions and 1 deletions
  1. +2
    -1
      libexec/rbenv-prefix
  2. +12
    -0
      test/prefix.bats

+ 2
- 1
libexec/rbenv-prefix 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

+ 12
- 0
test/prefix.bats 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"

Loading…
Cancel
Save