我正在尝试部署到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和environment.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发布于 2020-12-30 00:34:06
如果有人遇到同样的问题,我会发布我的解决方案。我遵循了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发布于 2021-02-20 17:40:28
切换到Bundler 2.1.4解决了我的问题。
从长远来看,用户必须安装Bundler2.1.4并使用它,但出于测试目的,我只是在Gemfile.lock中手动编辑了这一行
BUNDLED WITH
2.1.4我使用的是Ruby 2.7.2和Bundler 2.2.8 - Heroku buildpack提供了Bundler 2.1.4。
有趣的是,Heroku的Bundler bugs list没有关于2.2.8的任何内容。
https://stackoverflow.com/questions/65484162
复制相似问题