BeepDog BeepDog -4 years ago 84
Ruby Question

How can I use rvm within a Makefile?

Working on this project:

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 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:

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