Skip to content

Instantly share code, notes, and snippets.

@claybridges
Last active November 15, 2023 18:10
Show Gist options
  • Save claybridges/c289d5fa6e3e386e8921 to your computer and use it in GitHub Desktop.
Save claybridges/c289d5fa6e3e386e8921 to your computer and use it in GitHub Desktop.
Use rvm in a shell script
#!/usr/bin/env bash
# Xcode scripting does not invoke rvm. To get the correct ruby,
# we must invoke rvm manually. This requires loading the rvm
# *shell function*, which can manipulate the active shell-script
# environment.
# cf. http://rvm.io/workflow/scripting
# Load RVM into a shell session *as a function*
if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then
# First try to load from a user install
source "$HOME/.rvm/scripts/rvm"
elif [[ -s "/usr/local/rvm/scripts/rvm" ]] ; then
# Then try to load from a root install
source "/usr/local/rvm/scripts/rvm"
else
printf "ERROR: An RVM installation was not found.\n"
exit 128
fi
# rvm will use the controlling versioning (e.g. .ruby-version) for the
# pwd using this function call.
rvm use .
# aaaand your stuff here!
@draveness
Copy link

I copy this whole file into run script but not working on Xcode8?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment