Using Ruby shell scripts with RVM
After using RVM to manage my ruby environments I had some problems finding a solution to choose the correct ruby and gemset when running my ruby shell scripts. Here is what I have done to make it work.
First I created a separate gemset where I installed all needed gems into. I use one gemset for all scripts but of course it is up to you to use the default gemset or even one gemset per script.
> rvm use [email protected] --create
Getting a script to use a specific ruby version and gemset is also very easy. RVM creates a wrapper script in “.rvm/bin” for every installed gemset. So using the following as the shebang line will run your ruby script with the correct environment:
#!/usr/bin/env [email protected]