James P. Wright
James P. Wright

Reputation: 9131

Ruby "No Such File To Load - sqlite3" on OS X

I was trying to create a quick little script that would insert data into an SQLite db for me but I can't get past the first few steps. I have done "sudo gem install sqlite3-ruby", my Ruby version is 1.8.7 (I used the Ruby one click installer from rubyforge.org).

My script is incredibly simple. It looks like this:

#!/usr/bin/ruby -w
require "csv.rb"
require "sqlite3"

begin
  CSV.open('updateddata.sql', 'r') do |row|
     p row
end
rescue => err
    puts "Exception : #{err}"
    err
end

It never makes it past the line require "sqlite3". It just errors and tells me that it can't find that file to load.

I don't understand how it won't work even after using the One click installer (which is supposed to have SQLite built into the install).

I'm not even sure where to go from here.

I am not a Ruby developer at all, I just wanted to use it as a learning experience and to quickly complete this task for myself.

Upvotes: 2

Views: 1296

Answers (3)

iwan
iwan

Reputation: 7569

http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/43fc65132487f98e/?pli=1 using sqlite3-ruby gem solved my issue on this

Upvotes: 0

nicc
nicc

Reputation: 235

You can also add

export RUBYOPT=rubygems

to your profile.

Upvotes: 0

hrnt
hrnt

Reputation: 10142

Dunno if Ruby in OS X behaves differently, but normally you need to do require 'rubygems' before requiring any gems.

Upvotes: 7

Related Questions