mirror of
https://github.com/pyenv/pyenv.git
synced 2025-11-17 07:43:46 -05:00
Support GEM_HOME, add limited support for user-installed gems (#1436)
The rehash process will now discover executables in additional locations: - `~/.gem/ruby/<version>/bin/*` - `$GEM_HOME/bin` The `rbenv which` (and thus `rbenv exec`) command will also search these locations when looking up a command. This enables shims to dispatch calls to executables added by `gem install --user-install`. Note that this support is limited: - It will only work with C Ruby, as it's difficult to guess the `~/.gem/<engine>/<version>` directory for other Rubies without actually loading Ruby; - It will only work for RBENV_VERSION values in the format `X.Y.Z` and not "system".
This commit is contained in:
@@ -3,10 +3,11 @@
|
||||
load test_helper
|
||||
|
||||
create_executable() {
|
||||
local bin="${RBENV_ROOT}/versions/${1}/bin"
|
||||
mkdir -p "$bin"
|
||||
touch "${bin}/$2"
|
||||
chmod +x "${bin}/$2"
|
||||
local exe="${RBENV_ROOT}/versions/${1}/bin/${2}"
|
||||
[ -n "$2" ] || exe="$1"
|
||||
mkdir -p "${exe%/*}"
|
||||
touch "$exe"
|
||||
chmod +x "$exe"
|
||||
}
|
||||
|
||||
@test "empty rehash" {
|
||||
@@ -104,6 +105,42 @@ ruby
|
||||
OUT
|
||||
}
|
||||
|
||||
@test "user-install" {
|
||||
create_executable "${HOME}/.gem/ruby/3.0.0/bin/lolcat"
|
||||
create_executable "${HOME}/.gem/ruby/3.1.0/bin/pinecone"
|
||||
|
||||
assert [ ! -e "${RBENV_ROOT}/shims/lolcat" ]
|
||||
assert [ ! -e "${RBENV_ROOT}/shims/pinecone" ]
|
||||
|
||||
run rbenv-rehash
|
||||
assert_success ""
|
||||
|
||||
run ls "${RBENV_ROOT}/shims"
|
||||
assert_success
|
||||
assert_output <<OUT
|
||||
lolcat
|
||||
pinecone
|
||||
OUT
|
||||
}
|
||||
|
||||
@test "explicit gem home" {
|
||||
create_executable "${HOME}/mygems/bin/lolcat"
|
||||
create_executable "${HOME}/mygems/bin/pinecone"
|
||||
|
||||
assert [ ! -e "${RBENV_ROOT}/shims/lolcat" ]
|
||||
assert [ ! -e "${RBENV_ROOT}/shims/pinecone" ]
|
||||
|
||||
GEM_HOME="${HOME}/mygems" run rbenv-rehash
|
||||
assert_success ""
|
||||
|
||||
run ls "${RBENV_ROOT}/shims"
|
||||
assert_success
|
||||
assert_output <<OUT
|
||||
lolcat
|
||||
pinecone
|
||||
OUT
|
||||
}
|
||||
|
||||
@test "carries original IFS within hooks" {
|
||||
create_hook rehash hello.bash <<SH
|
||||
hellos=(\$(printf "hello\\tugly world\\nagain"))
|
||||
|
||||
Reference in New Issue
Block a user