如何在生产中尝试 运行 rails 控制台时修复 'spring is not part of the bundle'

How to fix 'spring is not part of the bundle' when trying to run rails console in production

我希望能够 运行 rails console 在安装了 Capistrano(3) 的应用程序上。

因此,我将 gem 'capistrano-rails-console', require: false 添加到 gemfile

下面给deploy.rb

server 'ip', port: 2, user: 'user', roles: [:web, :app, :db], primary: true

以及 Capfile 的以下内容 require 'capistrano/rails/console'

问题是cap production rails:console导致了下面的错误

00:00 rails:console
      01 $HOME/.rbenv/bin/rbenv exec bundle exec rails console -e production
Traceback (most recent call last):
    3: from bin/rails:7:in `<main>'
    2: from bin/rails:7:in `load'
    1: from /_some_path_/releases/20210808154555/bin/spring:14:in `<top (required)>'
/home/_user_/.rbenv/versions/2.7.2/lib/ruby/2.7.0/bundler/rubygems_integration.rb:346:in `block (2 levels) in replace_gem': spring is not part of the bundle. Add it to your Gemfile. (Gem::LoadError)

我该如何解决这个问题?

您可能需要将 Spring 添加到 Gemfile。

你能展示一下你的 Gemfile 吗?

如果你有类似的东西

group :development do
  gem 'spring'

您可以在区块上方推广它。