heroku-bundler:未能加载命令:rackup



我正在尝试向heroku部署一个在本地运行良好的模块化sinatra应用程序。这在heroku日志中:

2020-12-28T21:05:15.907560+00:00 heroku[web.1]: Starting process with command `bundle exec rackup config.ru -p 58645`
2020-12-28T21:05:18.738254+00:00 app[web.1]: bundler: failed to load command: rackup (/app/vendor/bundle/ruby/2.7.0/bin/rackup)
2020-12-28T21:05:18.738283+00:00 app[web.1]: Gem::Exception: can't find executable rackup for gem rack. rack is not currently included in the bundle, perhaps you meant to add it to your Gemfile?

命令bundle exec rackup config.ru -p 58645在本地运行良好。

这是我的config.ru

require_relative './config/environment.rb'
use EntreeController
use UserController
run ApplicationController

和环境.rb

APP_ENV = ENV["RACK_ENV"] || "development"
ENV['SINATRA_ENV'] ||= "development"
require 'require_all'
require 'bundler/setup'
Bundler.require(:default, ENV['SINATRA_ENV'])
require_all 'app'
require_all 'app/models'
require_all 'app/helpers'

和Procfile:

web: bundle exec rackup config.ru -p $PORT

如果有人遇到同样的问题,我会发布我的解决方案。我遵循了Rakefile上的指示:https://github.com/sinatra-activerecord/sinatra-activerecord.

一个解决方案是在部署到Heroku时完全删除Rakefile。另一个解决方案是只把这个放在Rakefile中:

require "sinatra/activerecord"
require "sinatra/activerecord/rake"
require "./app" # or whereever your app is

切换到Bundler 2.1.4解决了我的问题。

对于长期运行,必须安装bundler 2.1.4并使用它,但为了测试,我只是在Gemfile.lock:中手动编辑了这一行

BUNDLED WITH
2.1.4

我使用的是Ruby 2.7.2和Bundler 2.2.8——Heroku构建包提供了Bundler 2.1.4。

有趣的是,Heroku的Bundler错误列表中没有关于2.2.8的任何内容。

最新更新