2

I have a Rails application that runs on Ruby 1.9 and a shell script (Podcast Producer) that depends on Ruby 1.8.

I need to call the shell script from within the application. The Ruby Version Manager I use is rvm and the app runs within passenger. Now for obvious reasons it takes the wrong Ruby for the shell script (means, it loads rvm and bundler env and tries to start it within the same Environment, as the application runs in).

First line of the shell script:

#!/usr/bin/env ruby -I/usr/lib/podcastproducer

Call in the app

`/usr/bin/podcast`

How would you solve this?

Beffa
  • 915
  • 1
  • 8
  • 18

2 Answers2

2

There is do command in RVM. So you need to call:

%x{rvm 1.8.7 do /usr/bin/podcast}

or if /usr/bin/ is in $PATH you can run only:

%x{rvm 1.8.7 do podcast}
Hauleth
  • 22,873
  • 4
  • 61
  • 112
1

You can use rvm-shell (included in the RVM installation) to override the current Ruby/RVM version in your environment and explicitly use the system's default Ruby version (assuming you have not installed an alternate Ruby version as your system default, which you can check by running /usr/bin/ruby -v).

You should be able to use rvm-shell from within a Ruby script as follows:

`rvm-shell system -c '/usr/bin/podcast'`

The system argument instructs RVM to use the system's default Ruby version.

Stuart M
  • 11,458
  • 6
  • 45
  • 59