代码之家  ›  专栏  ›  技术社区  ›  hleinone

Heroku应用程序无法启动-“需要”:没有要加载的此类文件-SinatratesApp(LoadError)

  •  12
  • hleinone  · 技术社区  · 14 年前

    bamboo-mri-1.9.2 栈。当然,它在Ruby1.9.2上运行良好。但在生产时,在执行时启动时崩溃 config.ru 看起来是这样的:

    require 'sinatratestapp'
    run Sinatra::Application
    

    我的 .gems 文件:

    sinatra --version '>= 1.0'
    

    应用程序本身 sinatratestapp.rb :

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

    这就是我在这个项目中所拥有的一切,并尝试在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.
    

    我试着按照它的指导去做,但作为一个红宝石之角,我的考试没有结果。

    5 回复  |  直到 13 年前
        1
  •  38
  •   Community CDub    8 年前

    通过Heroku支持请求和 this question 我找到了解决办法。

    Ruby1.9.2不会自动在$load_路径中包含“.”。要解决此问题,请修改 config.ru 通过陈述 require './sinatratestapp' 而不是 require 'sinatratestapp' .

        2
  •  3
  •   recursive    14 年前

    您可以将以下行放入config.ru文件中,它也将解决此问题。这也将带来广泛的应用,因此它将带来1.9.2之前的行为:

    $load_path.unshift(dir.getwd)

    注:我不能在Heroku上测试

    我的问题是:让独角兽在没有gemfile、config.ru或config/unicorn.rb的情况下使用(ruby<1.9.2)sinatra应用程序正常工作。

        3
  •  1
  •   Joost Schuur    14 年前

    我相信我在试验西纳特拉的时候遇到了这个问题。Ruby1.9默认情况下不包括路径中的当前目录,因此您必须隐式声明 require 'sinatratestapp' 在我们 config.ru 文件。

        4
  •  0
  •   cramhead    13 年前

    谢谢你的小费。在Heroku邮报上没有提到.gems文件 http://blog.heroku.com/archives/2009/3/5/32_deploy_merb_sinatra_or_any_rack_app_to_heroku/

        5
  •  -1
  •   agentargo    14 年前

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

    我的.gems如下:

    sinatra
    hpricot