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?

2 Answers 2

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}
Sign up to request clarification or add additional context in comments.

1 Comment

also a valid answer, but in our case, we had better experience with rvm-shell
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.

3 Comments

additional you need to unset the RUBYOPT. RUBYOPT='' && rvm-shell system -c '/usr/bin/podcast'
Interesting, can you give some background on why that's necessary?
because in our environment bundler sets the RUBYOPT to -rbundler/setup which crashes

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.