【问题标题】:heroku bundler: failed to load command: rackupheroku bundler:加载失败命令:rackup
【发布时间】:2021-04-05 14:40:34
【问题描述】:

我正在尝试向 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

【问题讨论】:

    标签: ruby heroku sinatra


    【解决方案1】:

    如果有人遇到同样的问题,我会发布我的解决方案。我在这里遵循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
    

    【讨论】:

      【解决方案2】:

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

      从长远来看,必须安装 bundler 2.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 无关。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-06-30
        • 2023-04-09
        • 1970-01-01
        • 1970-01-01
        • 2022-08-17
        • 2018-11-11
        相关资源
        最近更新 更多