1
0
mirror of https://github.com/meineerde/dotfiles.git synced 2025-10-17 19:41:01 +00:00

Add ruby-exec helper to run a ruby executable with a specific ruby version

This supports chruby, rvm, and rbenv without any configuration
This commit is contained in:
Holger Just 2025-02-15 11:39:08 +01:00
parent 972f4fdad3
commit 46fee39ddb
No known key found for this signature in database

25
bin/ruby-exec Executable file
View File

@ -0,0 +1,25 @@
#!/usr/bin/env bash
usage() {
echo "Usage $0 RUBY_VERSION [ARGS...]"
exit $1
}
[ $# -lt 1 ] && usage 1
[ "${1:-}" = "--help" ] && usage 0
ruby="$1"
shift
if command -v chruby-exec >/dev/null 2>&1; then
exec chruby-exec "$ruby" -- "$@"
elif command -v rvm-exec >/dev/null 2>&1; then
exec rvm-exec "$ruby" "$@"
elif command -v rbenv >/dev/null 2>&1; then
export RBENV_VERSION="$ruby"
exec rbenv exec "$@"
else
echo "No Ruby version manager found, tried chruby, rvm, rbenv" >&2
exit 1
fi