2013-07-06 40 views
3

我正在使用:ruby-1.9.3-p392和sinatra-1.4.3。Ruby/Sinatra應用程序(文件)不運行(開始)

,當我跑我的文件,我得到這個錯誤:

/home/belka/.rvm/gems/[email protected]/gems/sinatra-1.4.3/lib/sinatra/base.rb:1408:in `run!': undefined method `run' for HTTP:Module (NoMethodError) 

from /home/belka/.rvm/gems/[email protected]/gems/sinatra-1.4.3/lib/sinatra/main.rb:25:in `block in <module:Sinatra>' 

我的代碼是一個新手西納特拉最簡單的代碼(hello.rb的):

require 'rubygems' 
require 'sinatra' 

get '/' do 
    'Hello World!' 
end 
+0

您可以顯示您正在使用的命令運行這個?另外,你不需要'require'rubygems'',參見https://gist.github.com/rtomayko/54177。 – iain

+0

我正在使用這個命令來運行我的.rb腳本:ruby hello.rb –

+0

看起來您嘗試啓動服務器時已加載了一個名爲'HTTP'的模塊。你的問題看起來有點像http://stackoverflow.com/questions/17334734/how-do-i-get-sinatra-to-work-with-httpclient,雖然我不明白這樣的事情會如何發生您發佈的代碼。 – matt

回答

5

我只是需要添加此代碼,並且我的sinatra應用程序現在仍在運行:

set :server, 'webrick' 
+1

我認爲這表明您的設置出了問題,因爲[此設置是默認設置的](http://www.sinatrarb.com/configuration.html#__handler_used_for_builtin_web_server)(略有不同,但仍然),應該只是工作。 – iain

+0

在我的設置中出現了什麼樣的錯誤,我剛剛安裝了sinatra gem:'gem install sinatra' –

+0

是那個環境/ gemset中安裝的唯一gem嗎?沙箱,沙箱,沙箱...;) – iain

相關問題