gpt4 book ai didi

ruby - Heroku 应用程序无法启动 - `require' : no such file to load -- sinatratestapp (LoadError)

转载 作者:数据小太阳 更新时间:2023-10-29 06:39:59 25 4
gpt4 key购买 nike

我正在尝试使用 bamboo-mri-1.9.2 堆栈运行我的 Heroku 应用程序。当然,它在 Ruby 1.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.

我已经尝试按照它的指导去做,但作为一个 Ruby 菜鸟,我的检查没有任何结果。

最佳答案

借助 Heroku 支持请求和 this question我找到了解决方案。

Ruby 1.9.2 不会自动包含“.”在 $LOAD_PATH 中。要解决此问题,请修改 config.ru,声明 require './sinatratestapp' 而不是 require 'sinatratestapp'

关于ruby - Heroku 应用程序无法启动 - `require' : no such file to load -- sinatratestapp (LoadError),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3973806/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com