Heroku的应用程序无法启动 - “需要”:没有这样的文件加载 - sinatratestapp(LoadError) [英] Heroku app fails to start - `require': no such file to load -- sinatratestapp (LoadError)
问题描述
我试图让我的Heroku应用程序使用 bamboo-mri-1.9.2
堆栈运行。当然,它在Ruby 1.9.2本地运行良好。但在生产过程中,它会在执行 config.ru
时看起来像这样崩溃:
I'm trying to get my Heroku app to run using the bamboo-mri-1.9.2
stack. Of course it's running fine locally on Ruby 1.9.2. But when on production it crashes during the startup on executing config.ru
which looks like this:
require 'sinatratestapp'
run Sinatra::Application
我的 .gems
file:
sinatra --version '>= 1.0'
而应用程序本身为 sinatratestapp.rb
:
require 'rubygems'
require 'sinatra'
get '/' do
"Hello from Sinatra on Heroku!"
end
这就是我在项目中所做的一切,并试图在Heroku上运行它结果:
That's all I've got in the project and trying to run that on Heroku results:
<internal:lib/rubygems/custom_require>:29:in `require': no such file to load -- sinatratestapp (LoadError)
from <internal:lib/rubygems/custom_require>:29:in `require'
from config.ru:1:in `block (3 levels) in <main>'
...
-----> Your application is requiring a file that it can't find.
Most often this is due to missing gems, or it could be that you failed
to commit the file to your repo. See http://docs.heroku.com/gems for
more information on managing gems.
Examine the backtrace above this message to debug.
我尝试过,但是作为Ruby noob,我的考试没有任何结果。 / p>
I've tried to do as it guides but as a Ruby noob my examinations have resulted nothing.
推荐答案
Ruby 1.9.2不会自动包含。在$ LOAD_PATH中。要解决这个问题,通过声明 require'./sinatratestapp'
而不是来修改
。 config.ru
需要'sinatratestapp'
Ruby 1.9.2 doesn't automatically include "." in the $LOAD_PATH. To workaround this, modify config.ru
by stating require './sinatratestapp'
instead of require 'sinatratestapp'
.
这篇关于Heroku的应用程序无法启动 - “需要”:没有这样的文件加载 - sinatratestapp(LoadError)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!