Heroku app无法启动-“require”:没有需要加载的文件- sinatratestapp (LoadError)

时间:2023-01-19 13:56:07

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:

我正在尝试使用bambo -mri-1.9.2堆栈运行Heroku应用程序。当然,它在Ruby 1.9.2上本地运行良好。但在生产时,在执行config.ru的启动过程中,它会崩溃,如下所示:

require 'sinatratestapp'
run Sinatra::Application

My .gems file:

我.gems文件:

sinatra --version '>= 1.0'

And the application itself as sinatratestapp.rb:

应用程序本身为sinatratestapp。rb:

require 'rubygems'
require 'sinatra'

get '/' do
  "Hello from Sinatra on Heroku!"
end

That's all I've got in the project and trying to run that on Heroku results:

这就是我在这个项目中所得到的,并试图在Heroku的结果中运行:

<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.

I've tried to do as it guides but as a Ruby noob my examinations have resulted nothing.

我试着做它的指导,但作为一个Ruby noob,我的考试没有结果。

5 个解决方案

#1


38  

By the help of Heroku support request and this question I found out the solution.

通过Heroku的支持请求和这个问题,我找到了解决方案。

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'.

Ruby 1.9.2没有在$LOAD_PATH中自动包含“.”。要解决这个问题,请通过声明“需要”来修改config.ru。“sinatratestapp”而不是“sinatratestapp”。

#2


3  

You can put the following line in your config.ru file and it will fix the issue as well. This is also going to carry application wide, so it will bring back the feeling of pre-1.9.2 behavior:

您可以在config.ru文件中添加以下行,它也将修复这个问题。这也将带来广泛的应用,因此它将带来1.9.2前行为的感觉:

$LOAD_PATH.unshift(Dir.getwd)

LOAD_PATH.unshift美元(Dir.getwd)

NOTE: I was unable to test on Heroku

注意:我无法在Heroku上测试

MY PROBLEM: Getting unicorn to behave properly with a (ruby < 1.9.2) sinatra application without a Gemfile, config.ru, or config/unicorn.rb.

我的问题是:让独角兽在没有Gemfile、config.ru或config/unicorn.rb的sinatra应用程序(ruby < 1.9.2)中正常运行。

#3


1  

I believe I ran into this problem when experimenting with Sinatra. Ruby 1.9 doesn't include the current directory in the path by default, so you have to implicitly state require 'sinatratestapp' in our config.ru file.

我相信我在实验Sinatra时遇到了这个问题。Ruby 1.9默认不包含路径中的当前目录,因此必须在config.ru文件中隐式地声明需要“sinatratestapp”。

#4


0  

Thanks for the tip. There was no mention of the .gems file in the Heroku post http://blog.heroku.com/archives/2009/3/5/32_deploy_merb_sinatra_or_any_rack_app_to_heroku/

谢谢你的提示。在Heroku发布的http://blog.herokuu.com/archives/2009/3/5/32_deploy_merb_sinatra_any_rack_app_to_heroku/中没有提到。gems文件。

#5


-1  

My Sinatra projects have the same layout and look about the same, the only difference is that in my .gems file I do not specify a version.

我的Sinatra项目具有相同的布局和外观,唯一的区别是在我的.gems文件中我没有指定版本。

my .gems looks like this:

我的。gems是这样的:

sinatra
hpricot

#1


38  

By the help of Heroku support request and this question I found out the solution.

通过Heroku的支持请求和这个问题,我找到了解决方案。

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'.

Ruby 1.9.2没有在$LOAD_PATH中自动包含“.”。要解决这个问题,请通过声明“需要”来修改config.ru。“sinatratestapp”而不是“sinatratestapp”。

#2


3  

You can put the following line in your config.ru file and it will fix the issue as well. This is also going to carry application wide, so it will bring back the feeling of pre-1.9.2 behavior:

您可以在config.ru文件中添加以下行,它也将修复这个问题。这也将带来广泛的应用,因此它将带来1.9.2前行为的感觉:

$LOAD_PATH.unshift(Dir.getwd)

LOAD_PATH.unshift美元(Dir.getwd)

NOTE: I was unable to test on Heroku

注意:我无法在Heroku上测试

MY PROBLEM: Getting unicorn to behave properly with a (ruby < 1.9.2) sinatra application without a Gemfile, config.ru, or config/unicorn.rb.

我的问题是:让独角兽在没有Gemfile、config.ru或config/unicorn.rb的sinatra应用程序(ruby < 1.9.2)中正常运行。

#3


1  

I believe I ran into this problem when experimenting with Sinatra. Ruby 1.9 doesn't include the current directory in the path by default, so you have to implicitly state require 'sinatratestapp' in our config.ru file.

我相信我在实验Sinatra时遇到了这个问题。Ruby 1.9默认不包含路径中的当前目录,因此必须在config.ru文件中隐式地声明需要“sinatratestapp”。

#4


0  

Thanks for the tip. There was no mention of the .gems file in the Heroku post http://blog.heroku.com/archives/2009/3/5/32_deploy_merb_sinatra_or_any_rack_app_to_heroku/

谢谢你的提示。在Heroku发布的http://blog.herokuu.com/archives/2009/3/5/32_deploy_merb_sinatra_any_rack_app_to_heroku/中没有提到。gems文件。

#5


-1  

My Sinatra projects have the same layout and look about the same, the only difference is that in my .gems file I do not specify a version.

我的Sinatra项目具有相同的布局和外观,唯一的区别是在我的.gems文件中我没有指定版本。

my .gems looks like this:

我的。gems是这样的:

sinatra
hpricot