Using Ruby Gem DBI

I want to access MySQL through ruby ​​on a shared linux server. I suppose I need to use the DBI module, but I cannot access it. I installed it as follows:

gem install -r dbi

He could not install it in the usual place, because I am on a shared server and do not 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 seemed to be successfully installed.

However, now when I try to execute it, I just get an error message. So my code is simple:

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 tried to set the environment variable LOAD_PATH to the directory where dbi.rb is located, but that didn't make any difference.

+3
source share
2 answers

. LOAD_PATH :

ruby -I$HOME/.gem/ruby/1.8/gems/dbi-0.4.1/lib/ dbi_test.r

LOAD_PATH UNIX. D'!

+3

, rubygems , , load_path

require 'rubygems'
require "dbi"
+12

All Articles