LoadError: no such file to load -- dm-sqlite-adapter
Asked Answered
B

3

9

I'm starting my first Sinatra App and I'm trying to use DataMapper. Everything is in the very early stages, as I can't get it to actually create the DB. I get "LoadError: no such file to load -- dm-sqlite-adapter" when I try to visit my page.

Here's the code from my Sinatra App so far:

require 'rubygems'
require 'sinatra'
require 'dm-core'
require 'dm-timestamps'
# Also tried require 'datamapper' , but the same issue shows up

DataMapper::setup(:default, "sqlite3://#{Dir.pwd}/raffle.db")

class Raffle 
    include DataMapper::Resource

    property :id,           Serial
    property :firstName,    String
    property :lastName,     String
    property :email,        String
    property :created_at,   DateTime

end

# Create, upgrade, or migrate DB Tables
DataMapper.auto_upgrade!

I have the gems installed, as gem list outputs:

*** LOCAL GEMS ***

activemodel (3.0.9, 3.0.3)
activerecord (3.0.9, 3.0.3)
activesupport (3.0.9, 3.0.3)
addressable (2.2.6)
arel (2.0.10, 2.0.4)
bcrypt-ruby (2.1.4)
builder (2.1.2)
bundler (1.0.15)
data_objects (0.10.6)
datamapper (1.1.0)
diff-lcs (1.1.2)
dm-aggregates (1.1.0)
dm-constraints (1.1.0)
dm-core (1.1.0)
dm-migrations (1.1.0)
dm-serializer (1.1.0)
dm-timestamps (1.1.0)
dm-transactions (1.1.0)
dm-types (1.1.0)
dm-validations (1.1.0)
do_sqlite3 (0.10.6)
fastercsv (1.5.4)
ffi (0.6.3)
i18n (0.5.0, 0.4.2)
json (1.5.3, 1.4.6)
mime-types (1.16)
rack (1.3.0, 1.2.1)
rack-test (0.5.6)
rake (0.8.7)
require_all (1.2.0)
rspec (2.6.0)
rspec-core (2.6.4)
rspec-expectations (2.6.0)
rspec-mocks (2.6.0)
shotgun (0.9)
sinatra (1.2.6, 1.1.0)
sqlite3 (0.1.1)
stringex (1.2.1)
tilt (1.3.2, 1.1)
typhoeus (0.2.4, 0.2.0)
tzinfo (0.3.29, 0.3.23)
uuidtools (2.1.2)

Any advice/insight is always appreciated.

Brindle answered 4/7, 2011 at 4:46 Comment(0)
B
22

I don't see the dm-sqlite-adapter gem in that list. Try installing it.

Bernitabernj answered 4/7, 2011 at 4:52 Comment(2)
That was it. I read somewhere that it was included it dm-migrations, and didn't need to be included. Thank you so much!Brindle
I had to add dm-sqlite-adapter to my Gemfile and restart shotgun for the changes to take effect. If you don't restart the server the issue won't get resolved.Headley
A
16

It may be a bit late for the original question, but in case anyone has a similar issue, putting an underscore "data_mapper" in require 'data_mapper' worked for me.

Ator answered 24/11, 2011 at 17:19 Comment(2)
Worked for me too. Are these different gems?Beckwith
They are technically different gems (with different download counts, etc) but they appear to have the same commit history. See rubygems.org/gems/datamapper vs rubygems.org/gems/data_mapperEzzell
E
1

You always need to explicitly add an adapter gem to your gemfile. Even data_mapper meta gem doesn't require any of the adapters.

Eustache answered 26/11, 2011 at 19:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.