Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions bin/exec-env
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,15 @@
current_script_path="${BASH_SOURCE[0]}"
ruby_plugin_dir="$(dirname "$(dirname "$current_script_path")")"

source "$ruby_plugin_dir/lib/utils.sh"

RUBYLIB=${RUBYLIB:-}
if [ "$RUBYLIB" = "" ]; then
export RUBYLIB="$ruby_plugin_dir/rubygems-plugin"
else
export RUBYLIB="$ruby_plugin_dir/rubygems-plugin:$RUBYLIB"
fi

if output=$(gem_user_dir); then
export GEM_HOME="$output"
fi
6 changes: 4 additions & 2 deletions bin/list-bin-paths
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env bash

gem_version="${ASDF_INSTALL_VERSION%.*}.0"
echo "bin lib/ruby/gems/$gem_version/bin"
# shellcheck source=/dev/null
source "$(dirname "$0")/../lib/utils.sh"

echo "bin lib/ruby/gems/$(ruby_minor_version)/bin"
15 changes: 15 additions & 0 deletions lib/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,18 @@ ruby_build_source_dir() {
ruby_build_path() {
echo "$(ruby_build_dir)/bin/ruby-build"
}

# Prevent ASDF from repeatedly invoking itself (e.g. via bin/exec-env)
# until the host machine runs out of memory
ruby_bypassing_asdf_callbacks() {
"$ASDF_INSTALL_PATH/bin/ruby" "$@"
}

ruby_minor_version() {
ruby_bypassing_asdf_callbacks -e 'puts RbConfig::CONFIG["ruby_version"]'
}

gem_user_dir() {
ruby_bypassing_asdf_callbacks -rrubygems -e 'puts Gem.user_dir'
}