I want to access MySQL through ruby on a shared linux server. I figure I need to use the DBI module, but I can’t seem to access it. I installed it as follows:
gem install -r dbi
It couldn’t install it in the normal location, since I’m on a shared server and don’t have permission:
WARNING: Installing to ~/.gem since /usr/lib/ruby/gems/1.8 and /usr/bin aren't both writable. WARNING: You don't have ~/.gem/ruby/1.8/bin in your PATH, gem executables will not run.
It did seem to install successfully though.
However, now when I try to require it, I just get an error. So my code is just:
require 'dbi'
and this gives the following error:
dbi_test.rb:1:in `require': no such file to load -- dbi (LoadError) from dbi_test.rb:1
I’ve tried setting the LOAD_PATH environment variable to the directory where dbi.rb is, but that didn’t make any difference.
I found the answer. I needed to specify LOAD_PATH on the command line as:
I had been setting LOAD_PATH as a standard UNIX environment variable. D’oh!