Heroku 不会 运行 他们的示例 sinatra 应用程序,错误是 bundler: failed to load command: rackup

Heroku won't run their sample sinatra app, error is bundler: failed to load command: rackup

如何让“hello world”sinatra 应用程序在 Heroku 上执行? Heroku 自己的示例应用程序失败:

对于全新的 heroku 应用程序,请遵循 Heroku 的 3 文件“hello world”Sinatra 部署说明,网址为: https://devcenter.heroku.com/articles/rack 构建失败 bundler: failed to load command: rackup

我已经在默认堆栈 (heroku-20) 上尝试过,并认为这可能是在 heroku-18 堆栈上尝试过的问题。同样的错误。

#config.ru
require './hello'
run Sinatra::Application

#hello.rb
require 'sinatra'
get '/' do
  "Hello World!"
end

#Gemfile
source 'https://rubygems.org'
gem 'sinatra'

给出:

heroku[web.1]: Starting process with command `bundle exec rackup config.ru -p ${PORT:-5000}`
heroku[web.1]: Process exited with status 1
heroku[web.1]: State changed from starting to crashed
heroku[web.1]: State changed from crashed to starting
app[web.1]: bundler: failed to load command: rackup (/app/vendor/bundle/ruby/3.0.0/bin/rackup)
app[web.1]: /app/vendor/bundle/ruby/3.0.0/gems/rack-2.2.3/lib/rack/handler.rb:45:in `pick': Couldn't find handler for: puma, thin, falcon, webrick. (LoadError)

尽管 Heroku 文档怎么说,Gemfile 需要一个网络服务器。

gem 'puma' 添加到 Gemfile 就成功了。