I have another ruby file that is required to run my app.
require ‘QuickBaseClient’ #this points to the QuickBaseClient.rb in the
same directory as the file I am running.
When I run this script from the command line: ruby init.rb it works
great.
When Cron tries to run it, it balks at the fact that it can’t find
QuickBaseClient
I imagine Cron is running this script in a temp dir, so I guess I need
to point at the original location of the QuickBaseClient.rb? If so, how
do I do that in code. I’ve always just used: require ‘QuickBaseClient’
and Ruby has found the file and used its methods.
require ‘QuickBaseClient’ #this points to the QuickBaseClient.rb
in the
same directory as the file I am running.
When I run this script from the command line: ruby init.rb it works
great.
When Cron tries to run it, it balks at the fact that it can’t find
QuickBaseClient
The file can not be found in any directory in $LOAD_PATH when cron
runs the ruby process. It works when you run init.rb from the same
directory because “.” is in the $LOAD_PATH. Try:
require File.dirname(FILE) + “/QuickBaseClient” # FILE is the
current source file
Another tip – files are usually named like this: quick_base_client.rb
require ‘QuickBaseClient’ #this points to the QuickBaseClient.rb
in the
same directory as the file I am running.
When I run this script from the command line: ruby init.rb it works
great.
When Cron tries to run it, it balks at the fact that it can’t find
QuickBaseClient
The file can not be found in any directory in $LOAD_PATH when cron
runs the ruby process. It works when you run init.rb from the same
directory because “.” is in the $LOAD_PATH. Try:
require File.dirname(FILE) + “/QuickBaseClient” # FILE is the
current source file
Another tip – files are usually named like this: quick_base_client.rb
– Daniel
Hi Daniel,
Thank you for the response. I am a little confused. When you mean the
source file, is that the QuickBaseClient.rb that is located in the same
folder as my init.rb? Also, should the file name be in quotes? Thank
you for your help!
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.