1

Heads up, ruby n00b testing the waters -

OS - OSX 10.7

test.rb in /Library/WebServer/CGI-Executables:

#!/usr/bin/ruby
require 'mysql'

con = Mysql.new('localhost', 'root', 'root', 'rubytest')
rs = con.query('select * from people')
rs.each_hash { |h| puts h['name']}  
con.close

When running from the command line ruby test.rb, I get the fields within just fine. When hitting test.rb from localhost (http://localhost/cgi-bin/test.rb), I get a 500 and a nag in the error log about mysql being missing-

Apache error log:

[Fri Aug 31 23:47:22 2012] [error] [client 127.0.0.1] /Library/WebServer/CGI-Executables/test.rb:3:in `require': no such file to load -- mysql (LoadError)
[Fri Aug 31 23:47:22 2012] [error] [client 127.0.0.1] \tfrom /Library/WebServer/CGI-Executables/test.rb:3
[Fri Aug 31 23:47:22 2012] [error] [client 127.0.0.1] Premature end of script headers: test.rb

My export paths in ~/.bashrc:

export DYLD_LIBRARY_PATH="/usr/local/mysql/lib"
export PATH="$PATH:/usr/local/mysql/bin"
export PS1="$ "

If this is any help, running gem env | grep 'RUBY EXECUTABLE'

RUBY EXECUTABLE: /Users/robertcox/.rvm/rubies/ruby-1.9.2-p318/bin/ruby

Any help appreciated

2
  • Just to be sure: You use ruby for pure cgi scripting, not in connection with the rails framework? Commented Sep 1, 2012 at 7:11
  • Have a look here, if that helps you out. You are probably just not including enough. stackoverflow.com/questions/5664553/… Commented Sep 1, 2012 at 7:20

1 Answer 1

0

Maybe you need update gem install mysql2

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.