When nzbget is started via launchagent, rvm ruby script doesn't work

This script does not work when launched from Nzbget if Nzbget is started
via LaunchAgent.
If I start Nzbget with the same arguments from the command line, it
works fine.

Here are the files and output:
https://gist.github.com/anonymous/10889103
-com.tv.nzbget.plist is located in ~/Library/Launchagents
-push.rb is the Nzbget post processing script
-test-rvm.txt is the output of the script for debugging
I am using RVM with my default ruby set to 2.1.1
for some reason, when started by launchd, Nzbget is using the system
ruby (2.0.0 on OS X 10.9)

when Nzbget is started by a launchagent

(~/Library/Launchagents/com.tv.nzbget.plist)
Chancho
ruby 2.0.0p247 (2013-06-27 revision 41674)
[universal.x86_64-darwin13]

when Nzbget is started from a terminal

(/usr/local/bin/nzbget -D -c /Users/Chancho/.nzbget.conf)

I get

Chancho
ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-darwin13.0

If I explicitly call the rvm ruby path in my shebang, I still get the
same results.
I would like to be able to use my Rvm rubies and gemsets.
Any ideas how to fix it, or why this is happening?
Thanks

UPDATE:

I am calling my ruby script from a shell script that sets the Rvm ruby
I’d still like to know if there is a easier way. here is my script:
https://gist.github.com/anonymous/10982308

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs