WebFaction
Community site: login faq

Hello,

I have a problem to run a crontab for a ruby task:

/1 * * * /usr/local/bin/ruby /home/account/webapps/account/gems/gems/ar_mailer_rails3-2.1.12/bin/ar_sendmail_rails3 -o -b 20 -c /home/account/webapps/account/account -e production > /home/account/webapps/account/account/log/cron_mails.log 2>&1

The error: ar_sendmail_rails3:3:in `require': no such file to load -- ar_mailer_rails3/ar_sendmail (LoadError)

I don't know if it is a gem or ruby problem configuration ? Routes problem ? The gem works properly locally on my mac when I just ran "ar_sendmail_rails3". And the gem is properly installed because I used it directly from my rails app...

Thanks !

asked 02 Aug '11, 12:14

muqaddar
178
accept rate: 0%


Hi,

The problem here is that your apps are running on Ruby1.8.7ee instead of Ruby1.8 so you'll need to change that path to:

/home/user/webapps/appname/gems/bin/ruby

(this is actually a symlink to /usr/local/ruby1.8.7ee/bin/ruby)

Then you are getting the error because cron can't find your gems. To fix that you will need to set:

TMPDIR=/home/user/webapps/appname/tmp GEM_HOME=/home/user/webapps/appname/gems

in your cron before the path to Ruby in order to pick up your gems and the correct temp directory. You can see an example of this if you run:

cat /home/user/webapps/appname/bin/start

Once you set that you should be good to go.

The reason it works on your local computer is because it is installed "system wide" (on your default path) not in a specific directory that you need to add to your path.

permanent link

answered 02 Aug '11, 17:30

klynton
1.6k1210
accept rate: 41%

Hi klynton,

Thanks you for your reply. I understand now. I have yet a problem for the rails path that I don't understand, because all looks good.

Have a look:

TMPDIR=/home/wokfilms/webapps/wokfilms/tmp GEM_HOME=/home/wokfilms/webapps/wokfilms/gems /home/wokfilms/webapps/wokfilms/gems/bin/ruby /home/wokfilms/webapps/wokfilms/gems/bin/ar_sendmail_rails3 -o -b 20 --chdir /home/wokfilms/webapps/wokfilms/wokfilms -e production

And the error: ar_sendmail_rails3 must be run from a Rails application's root to deliver email. /home/wokfilms/webapps/wokfilms/wokfilms does not appear to be a Rails application root.

Or, this directory IS the rails root directory for my app ! Do you have an idea ?

(03 Aug '11, 03:06) muqaddar

I think your rails root would be /home/wokfilms/webapps/wokfilms. Try that and let me know if it works.

(03 Aug '11, 03:08) klynton

Ok, I found the solution adding the library path for the gem.

TMPDIR=/home/wokfilms/webapps/wokfilms/tmp LD_LIBRARY_PATH=/home/wokfilms/lib:/home/wokfilms/webapps/wokfilms/gems/gems/ar_mailer_rails3-2.1.12/lib GEM_HOME=/home/wokfilms/webapps/wokfilms/gems 
/home/wokfilms/webapps/wokfilms/gems/bin/ruby 
/home/wokfilms/webapps/wokfilms/gems/bin/ar_sendmail_rails3 -o -b 20 
--chdir /home/wokfilms/webapps/wokfilms/wokfilms -e production 
> /home/account/webapps/account/account/log/cron_mails.log 2>&1

Thanks you !

(04 Aug '11, 03:51) muqaddar

Great! Thanks for the follow up.

(04 Aug '11, 04:25) klynton
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×28
×1

question asked: 02 Aug '11, 12:14

question was seen: 2,796 times

last updated: 04 Aug '11, 04:25

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM