Any experience or ideas?
If the problem is in gems, try adding require “rubygems” before require
“mysql”.
(the same may be achieved by setting RUBYOP«=rubygems in the
environment)
If it doesn’t help, please post the exact error message with exception
trace.
`gem_original_require’: No such file to load – mysql (LoadError)
I’m able to call the same script from crontab by adding
$LOAD_PATH << File.expand_path(File.dirname(FILE))
Any ideas on massaging the path?
cheers
What came to my mind is whether are you using the same ruby in those two
cases?
Other than that, 1. look up where the mysql lib/gem resides, 2. print
out $LOAD_PATH in both cases and compare.
You could do system(“gem list”) as well to check whether gems can find
the mysql gem.
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in gem_original_require': No such file to load -- mysql (LoadError) from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:inrequire’
from /Users/mark/scripts/myscript.rb:31
Line 31 is
require ‘mysql’
So, looks like it can’t find the gem in the path.
I’m able to call the same script from crontab by adding
$LOAD_PATH << File.expand_path(File.dirname(FILE))
PHP probably doesn’t run as your user account, so it might use a
different PATH. The path you’re using for Ruby is for YOUR user’s
shell login.
one way to verify it is to check the user id and process id. you can
use tail for that.
PHP probably uses something set in /env
You would have the same path to Ruby if you didn’t have the path
variable set by the dot file in your user account directory when you
do a shell login.
PHP often runs as whatever Apache runs as for user id, and it’s not
your user id.
The PHP script may be owned by you, but the process is owned by PHP
or Apache.
The PHP CLI works differently. It runs under your uid, just as Ruby
would.
Anything run by Apache or another server will have a different uid.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.