views:

38

answers:

1

I am using the following command:

script/runner -e production ~/apps/application/current/vendor/gems/whenever-0.4.1/bin/whenever

but I get the error:

/usr/lib/ruby/1.8/optparse.rb:1445:in `complete': invalid option: -e (OptionParser::InvalidOption)
        from /usr/lib/ruby/1.8/optparse.rb:1443:in `catch'
        from /usr/lib/ruby/1.8/optparse.rb:1443:in `complete'
        from /usr/lib/ruby/1.8/optparse.rb:1282:in `parse_in_order'
        from /usr/lib/ruby/1.8/optparse.rb:1249:in `catch'
        from /usr/lib/ruby/1.8/optparse.rb:1249:in `parse_in_order'
        from /usr/lib/ruby/1.8/optparse.rb:1243:in `order!'
        from /usr/lib/ruby/1.8/optparse.rb:1334:in `permute!'
        from /usr/lib/ruby/1.8/optparse.rb:1355:in `parse!'
        from /home/user/apps/application/current/vendor/gems/whenever-0.4.1/bin/whenever:11
        from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `eval'
        from /home/user/apps/application/releases/20100109060255/vendor/rails/railties/lib/commands/runner.rb:46
        from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
        from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
        from script/runner:3
+1  A: 

Try setting your Rails environment as an environment variable on the command line, like this:

RAILS_ENV=production script/runner /your_path/file_to_run.rb
Mark Westling
this works; is there a way to pass the ruby location /usr/bin/ruby RAILS_ENV=production script/runner /your_path/file_to_run.rbthrows an error?
Marcus
Sure, try "RAILS_ENV=production /usr/bin/ruby script/runner your_path.rb". Alternatively, you could use two lines: "export RAILS_ENV=production" followed by "/usr/bin/ruby script/runner your_path.rb". What you're doing is setting the environment variable RAILS_ENV before executing script/runner, and you can do that either by using the export command or by using the "variable=value command" alternative form in the shell.
Mark Westling
Your first suggestion worked great, thank you.
Marcus
Glad to help. Could you mark this answer as being correct?
Mark Westling