tags:

views:

169

answers:

1

I have following code

require 'rubygems'
require 'sinatra'

get '/' do
  'Hello World!'
end


gem list sinatra

*** LOCAL GEMS ***

sinatra (1.0, 0.9.4)


ruby -v
ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin10.2.0]

Error

 ruby myapp.rb 
["==", "===", "=~", "__id__", "__send__", "class", "clone", "display", "dup", "enum_for", "eql?", "equal?", "extend", "freeze", "frozen?", "hash", "id", "include", "inspect", "instance_eval", "instance_exec", "instance_of?", "instance_variable_defined?", "instance_variable_get", "instance_variable_set", "instance_variables", "is_a?", "kind_of?", "method", "methods", "nil?", "object_id", "private", "private_methods", "protected_methods", "public", "public_methods", "respond_to?", "send", "singleton_methods", "taguri", "taguri=", "taint", "tainted?", "tap", "to_a", "to_enum", "to_s", "to_yaml", "to_yaml_properties", "to_yaml_style", "type", "untaint"]
./sinatra.rb:17: undefined method `get' for main:Object (NoMethodError)
    from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
    from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
    from myapp.rb:3
+3  A: 

Is it possible that you have file named "sinatra.rb" in the same folder as the file you're running? "Require" checks the local directory first, so if there's one there, it won't go find the real gem.

[1] https://sinatra.lighthouseapp.com/projects/9779/tickets/295-sinatra-hello-world-error

Harpastum