我想通过共享linux服务器上的ruby访问MySQL.我想我需要使用DBI模块,但我似乎无法访问它.我安装如下:
gem install -r dbi
它无法在正常位置安装它,因为我在共享服务器上并且没有权限:
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.
它似乎确实安装成功.
但是,现在当我尝试要求它时,我只是得到一个错误.所以我的代码只是:
require 'dbi'
这会给出以下错误:
dbi_test.rb:1:in `require': no such file to load -- dbi (LoadError) from dbi_test.rb:1
我已经尝试将LOAD_PATH环境变量设置为dbi.rb所在的目录,但这没有任何区别.
如果它作为gem安装,您还可以在解决问题之前需要rubygems而无需设置load_path
require 'rubygems' require "dbi"