问题
I wanted to try Sinatra as I've heard it's better for the newbie web-dev than rails.. and in general I prefer more minimalistic than not.
To premise this, I'm using ruby 2 and whatever version of sinatra that gem install gets.
All I've done so far is the basic
require 'sinatra'
get '/' do
'Hello, World!'
end
try to run the server with ruby basics.rb and it throws this at me:
/home/ch35hir3/.rvm/gems/ruby-2.0.0-p247/gems/thin-2.0.0.pre/lib/thin/server.rb:108:in `initialize': wrong number of arguments (4 for 0..3) (ArgumentError)
from /home/ch35hir3/.rvm/gems/ruby-2.0.0-p247/gems/rack- 1.5.2/lib/rack/handler/thin.rb:14:in `new'
from /home/ch35hir3/.rvm/gems/ruby-2.0.0-p247/gems/rack -1.5.2/lib/rack/handler/thin.rb:14:in `run'
from /home/ch35hir3/.rvm/gems/ruby-2.0.0-p247/gems/sinatra-1.4.4/lib/sinatra/base.rb:1488:in `start_server'
from /home/ch35hir3/.rvm/gems/ruby-2.0.0-p247/gems/sinatra-1.4.4/lib/sinatra/base.rb:1426:in `run!'
from /home/ch35hir3/.rvm/gems/ruby-2.0.0-p247/gems/sinatra-1.4.4/lib/sinatra/main.rb:25:in `block in <module:Sinatra>'
Of course I tried googling the error, and just general poking around but I don't really know what to do.
回答1:
Your thin
gem is a pre
version. Removing that gem and using thin 1.6.0 should fix the problem. gem uninstall thin && gem install thin
. Alternatively, you could use a different server, like puma. gem install puma
, then under require 'sinatra'
add configure { set :server, :puma }
来源:https://stackoverflow.com/questions/19579984/sinatra-server-wont-start-wrong-number-of-arguments