Skip to content

Commit

Permalink
fix: switch ruby for system argument with rbenv (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
lacostej authored Dec 14, 2023
1 parent be5e0ee commit 666f2d1
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/scripts/switch-ruby.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
#!/usr/bin/env bash

if command -v rbenv >/dev/null 2>&1; then
version=$(rbenv versions --bare | grep "$ORB_VAL_RUBY_VERSION" | head -n 1)
if [ -z "$version" ]; then
printf "\nNo Rubies installed that match version %s\n" "$ORB_VAL_RUBY_VERSION"
printf "\nInstalled versions:\n"
rbenv versions
exit 1
ruby_ver="$ORB_VAL_RUBY_VERSION"
if [[ "$ruby_ver" != "system" ]]; then
ruby_version=$(rbenv versions --bare | grep "$ORB_VAL_RUBY_VERSION" | head -n 1)
if [[ -z "$ruby_version" ]]; then
printf "\nNo Rubies installed that match version %s\n" "$ORB_VAL_RUBY_VERSION"
printf "\nInstalled versions:\n"
rbenv versions
exit 1
fi
else
ruby_version="system"
fi

rbenv global "$version"
rbenv global "$ruby_version"
rbenv rehash

printf "\nSet Ruby version succesfully:\n"
Expand Down

0 comments on commit 666f2d1

Please sign in to comment.