1
votes

I have installed sinatra gems on local machine(Ruby 2.x) and server(Ruby 1.8.x). It worked well in my local machine but failing in server. Please help me in resolving this if anyone else encountered this before.

require 'rubygems'
require 'sinatra'

get '/' do
  'Hello world!'
end

ruby --version

ruby 1.8.7 (2013-06-27 patchlevel 374) [x86_64-linux]

gem list
rack (1.6.4)
rack-protection (1.5.3)
sinatra (1.4.6)
tilt (2.0.1)

Exception

ruby/1.8/gems/rack-1.6.4/lib/rack/handler.rb:22:in const_get': wrong number of arguments (2 for 1) (ArgumentError) from \\..gem/ruby/1.8/gems/rack-1.6.4/lib/rack/handler.rb:22:inget' from \..gem/ruby/1.8/gems/sinatra-1.4.6/lib/sinatra/base.rb:1777:in detect_rack_handler' from \\..gem/ruby/1.8/gems/sinatra-1.4.6/lib/sinatra/base.rb:1775:ineach' from \..gem/ruby/1.8/gems/sinatra-1.4.6/lib/sinatra/base.rb:1775:in detect_rack_handler' from \\..gem/ruby/1.8/gems/sinatra-1.4.6/lib/sinatra/base.rb:1437:inrun!' from \..gem/ruby/1.8/gems/sinatra-1.4.6/lib/sinatra/main.rb:25

2

2 Answers

3
votes

Ruby 1.8.7:

const_get(sym) => obj

Ruby 2.1.0:

const_get(sym, inherit=true) → obj

So, even though Sinatra claims that it supports ruby 1.8.7, Rack apparently does not. You can try downgrading Rack to last version supporting 1.8.7 (I have no clue which would that be). But why would you use 1.8.7 in 2015 anyway?

-2
votes

For ruby 1.8.7 and sinatra 1.4.6. update the Gemfile.lock update rack version.

rack (1.6.1) bundle install