首页 > 解决方案 > 尝试在生产中运行rails控制台时如何修复“spring不是捆绑包的一部分”

问题描述

我希望能够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)

我怎样才能解决这个问题?

标签: ruby-on-railscapistranorbenvcapistrano3

解决方案


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

你能展示你的 Gemfile 吗?

如果你有类似的东西

group :development do
  gem 'spring'

您可以将其提升到块上方。


推荐阅读