Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a launchctl job I define as such:


When I run manually, the script works fine, as it uses the currently configured rvm version of ruby. When I run this through launchctl, the system version of Ruby is used, which breaks the script. How can I get this script to run with the right version of ruby available?

share|improve this question

Change to set environment variable PATH before it invokes any programs that depend on PATH being set correctly.

share|improve this answer
The only problem is that RVM dynamically points to the current Ruby, which could be anywhere, e.g. ~/.rvm/rubies/ruby-1.9.3-head/bin/ruby. There's no fixed path that can be included. – slhck Jun 12 '12 at 19:14

The best way will be to use an rvm "wrapper", which loads the ruby environment and then runs the script. For more info:

$ rvm help wrapper


$ rvm wrapper 2.0.0 hello
$ hello_ruby -e "puts RUBY_VERSION"
$ hello_rake -T
$ which hello_ruby # => /Users/me/.rvm/bin/hello_ruby


And you can use "/Users/me/.rvm/bin/hello_ruby" as the executable in your launchd configs, and the rvm environment will be set up for you.

This is also really nice to do without specifying the exact ruby version so when a patch level comes out, upgrade rvm and your wrappers will point to the newer patched ruby without needing to unload/load the launchd files.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.