Add /usr/etc/rbenv.d to hooks path (#1587)

The directory /usr/etc is an optional directory and used by
Fedora, RHEL 9, and openSUSE. The purpose of /usr/etc is to store
distribution-provided configuration files that can be overridden
by user-modified files in /etc.

Also used in the sister project pyenv/pyenv#3039

Co-authored-by: Mislav Marohnić <git@mislav.net>
This commit is contained in:
Tom Schraitle 2024-08-27 16:10:43 +02:00 committed by GitHub
parent bf1fcd346b
commit c335ab83de
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 3 deletions

View file

@ -82,7 +82,7 @@ if [ ! "${libexec_dir%/*}"/rbenv.d -ef "$RBENV_ROOT"/rbenv.d ]; then
# Add rbenv's own `rbenv.d` unless rbenv was cloned to RBENV_ROOT # Add rbenv's own `rbenv.d` unless rbenv was cloned to RBENV_ROOT
RBENV_HOOK_PATH="${RBENV_HOOK_PATH}:${libexec_dir%/*}/rbenv.d" RBENV_HOOK_PATH="${RBENV_HOOK_PATH}:${libexec_dir%/*}/rbenv.d"
fi fi
RBENV_HOOK_PATH="${RBENV_HOOK_PATH}:/usr/local/etc/rbenv.d:/etc/rbenv.d:/usr/lib/rbenv/hooks" RBENV_HOOK_PATH="${RBENV_HOOK_PATH}:/usr/etc/rbenv.d:/usr/local/etc/rbenv.d:/etc/rbenv.d:/usr/lib/rbenv/hooks"
for plugin_hook in "${RBENV_ROOT}/plugins/"*/etc/rbenv.d; do for plugin_hook in "${RBENV_ROOT}/plugins/"*/etc/rbenv.d; do
RBENV_HOOK_PATH="${RBENV_HOOK_PATH}:${plugin_hook}" RBENV_HOOK_PATH="${RBENV_HOOK_PATH}:${plugin_hook}"
done done

View file

@ -64,7 +64,7 @@ load test_helper
@test "RBENV_HOOK_PATH includes etc/rbenv.d folders" { @test "RBENV_HOOK_PATH includes etc/rbenv.d folders" {
mkdir -p "$RBENV_ROOT"/plugins/rbenv-foo/etc/rbenv.d mkdir -p "$RBENV_ROOT"/plugins/rbenv-foo/etc/rbenv.d
run rbenv echo -F: "RBENV_HOOK_PATH" run rbenv echo -F: "RBENV_HOOK_PATH"
assert_line 6 "${RBENV_ROOT}/plugins/rbenv-foo/etc/rbenv.d" assert_line 7 "${RBENV_ROOT}/plugins/rbenv-foo/etc/rbenv.d"
} }
@test "RBENV_HOOK_PATH preserves value from environment" { @test "RBENV_HOOK_PATH preserves value from environment" {
@ -78,5 +78,5 @@ load test_helper
@test "RBENV_HOOK_PATH includes rbenv built-in plugins" { @test "RBENV_HOOK_PATH includes rbenv built-in plugins" {
unset RBENV_HOOK_PATH unset RBENV_HOOK_PATH
run rbenv echo "RBENV_HOOK_PATH" run rbenv echo "RBENV_HOOK_PATH"
assert_success "${RBENV_ROOT}/rbenv.d:${BATS_TEST_DIRNAME%/*}/rbenv.d:/usr/local/etc/rbenv.d:/etc/rbenv.d:/usr/lib/rbenv/hooks" assert_success "${RBENV_ROOT}/rbenv.d:${BATS_TEST_DIRNAME%/*}/rbenv.d:/usr/etc/rbenv.d:/usr/local/etc/rbenv.d:/etc/rbenv.d:/usr/lib/rbenv/hooks"
} }