BeepDog BeepDog -4 years ago 84
Ruby Question

How can I use rvm within a Makefile?

Working on this project: https://github.com/cucumber/bool

There's a makefile to construct the various items, and I'd like to use RVM to be able to switch between rubies for the stuff within the ruby directory, however, when I give the makefile commands to switch rubies, I get a nasty error

RVM is not a function, selecting rubies with 'rvm use ...' will not work.

You need to change your terminal emulator preferences to allow login shell.
Sometimes it is required to use `/bin/bash --login` as the command.
Please visit https://rvm.io/integration/gnome-terminal/ for a example.


Of course, it works just fine if I issue
rvm use 1.9.3
on the command line, so this is a symptom of something else, but I'm not sure what.

Answer Source

When you call RVM from cron (or a Makefile, I would expect) it's important to set up the right environment. The Scout team have a great blog article explaining this:

http://blog.scoutapp.com/articles/2010/09/07/rvm-and-cron-in-production

The important part is ensuring you have a full login shell so you have access to RVM.

/bin/bash -l -c 'the_command_inside_makefile"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download