Question

I have configured lighttpd for CGI. Things are basically working except for requiring gems with Ruby. For example this script

#!/usr/bin/env ruby

require 'cgi'
require 'rubygems'
require 'mysql2'

cgi = CGI.new

print "Content-Type: text/plain\n\n" 
print "Hello, world!"

gives me cannot load such file -- mysql2 (LoadError). If I remove the require 'mysql2' it works fine. I installed mysql2 as root, and other users can require it without issue.

What is also odd is that Gem.available? 'mysql2' is true in the CGI script, so it seems that the gem is being detected in some way.

Was it helpful?

Solution

I fixed it, but I'm still not sure what the issue was. As root, I did

gem update --system
gem install --no-user-install mysql2

For some reason the permissions ended up wrong so I had to do

chmod -R o+rX /usr/local/share/gems1.9

Then everything worked again. Also require 'rubygems' ended up being unnecessary in the CGI script.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top