6

I was trying to learn about the Sinatra ruby framework by following this tutorial:

http://net.tutsplus.com/tutorials/ruby/singing-with-sinatra-the-recall-app-2/

however, after running the gem install and writing a simple sinatra server in test.rb like so:

require 'sinatra'
require 'datamapper'

get '/' do 
  "Hello, World!"
end

but when I run the command ruby test.rb, I get the following error:

/usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': no such file to load -- datamapper (LoadError)
    from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from datamapper_test.rb:2:in `<main>'
glenn@ubuntu:~/Dropbox/Repositories/sandbox/sinatra$ ruby datamapper_test.rb 
/usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': no such file to load -- datamapper (LoadError)
    from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from test.rb:3:in `<main>'

it seems as though it cannot find the datamapper gem. how can I fix this?

EDIT: using ruby 1.9.2

EDIT (again): (parital) output from gem list:

data_mapper (1.2.0)
data_objects (0.10.8)
datamapper (1.2.0)
devise (1.4.5)
directory_watcher (1.4.0)
dm-aggregates (1.2.0)
dm-constraints (1.2.0)
dm-core (1.2.0)
dm-do-adapter (1.2.0)
dm-migrations (1.2.0)
dm-serializer (1.2.1)
dm-sqlite-adapter (1.2.0)
d    m-timestamps (1.2.0)
dm-transactions (1.2.0)
dm-types (1.2.1)
dm-validations (1.2.0)
do_sqlite3 (0.10.8)
sinatra (1.3.2, 1.2.6)
sqlite3 (1.3.5, 1.3.4)
sqlite3-ruby (1.3.3)
GSto
  • 38,666
  • 37
  • 126
  • 179
  • yea, right. Writing funny comments and then deleting them again. My last comment is a response to a deleted comment about requiring rubygems... – three Feb 20 '12 at 21:23
  • @three: My mistake. I use Ruby 1.8.7, so the first thing I noticed was that :) Anyway, it seems my answer is useless now, so I'll delete it. – Vicky Chijwani Feb 20 '12 at 21:33
  • :) Time to update for you! 1.9 is doing a great job. – three Feb 20 '12 at 22:14

2 Answers2

26

You need to require 'data_mapper', not datamapper.

Note there is a datamapper gem as well as a data_mapper gem, but they are the same thing, just different names. You need use data_mapper as the library name in both of them.

As far as I can tell datamapper is a straight copy of data_mapper:

$ diff -r data_mapper-1.2.0/ datamapper-1.2.0/
diff -r data_mapper-1.2.0/Rakefile datamapper-1.2.0/Rakefile
21c21
< GEM_NAME         = 'data_mapper'
---
> GEM_NAME         = 'datamapper'
matt
  • 74,317
  • 7
  • 140
  • 183
0

gem install datamapper in your terminal might help :) But you will also need a database and an adapter and you will want to use the gem somehow. Good luck and have fun with dm + sinatra!

three
  • 7,596
  • 3
  • 30
  • 37
  • i did run gem install datamapper, and have sqlite3 and the nessecary gems installed as well. – GSto Feb 20 '12 at 21:45