Ruby server won't start with neography

121 views Asked by At

I have ruby file which im running in my mac with OSX 10.9 that is a combination of sinatra and geography which i have both installed. when i use require 'sinatra' on the file everything is fine, but when i insert require 'neography' it gives me this error when trying to run the file.

/Users/AJ/.rvm/gems/ruby-2.1-head/gems/sinatra-1.4.4/lib/sinatra/base.rb:1488:in `start_server': undefined method `run' for HTTP:Module (NoMethodError)
        from /Users/AJ/.rvm/gems/ruby-2.1-head/gems/sinatra-1.4.4/lib/sinatra/base.rb:1426:in `run!'
        from /Users/AJ/.rvm/gems/ruby-2.1-head/gems/sinatra-1.4.4/lib/sinatra/main.rb:25:in `block in <module:Sinatra>'

What could be a possible reason for this error? Thanks in advance

1

There are 1 answers

0
matt On

Neography depends on httpclient, which in turn defines a module named HTTP.

When Sinatra tries to determine which server to use one of the options it tries is the net-http-server, whose Rack handler class is also named HTTP. This causes a name collision where Sinatra thinks the HTTP module in httpclient is the net-http-server and tries to run it as such, causing the error you see.

If you have another server installed, e.g. Thin, it will likely be detected before HTTP so you won’t see this error, but you are probably better explicitly setting the server to use. You can add something like

set :server, thin

to your application file to specify Thin as your server (you’ll need to install the thin gem first – you could also use Webrick). You could also specify this on the command line if you wanted: ruby my_app.rb -s thin, but I think you’d be better of adding it to your code to avoid problems in the future.