ruby-on-railscapistranorbenvcapistrano3

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


I'd like to be able to run rails console on an app installed with Capistrano(3).

So, I added gem 'capistrano-rails-console', require: false to the gemfile

the following to the deploy.rb

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

and the following to the Capfile require 'capistrano/rails/console'

The problem is that cap production rails:console leads to the following error

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)

How can I fix this?


Solution

  • You probably need to add Spring to the Gemfile.

    Can you show your Gemfile?

    If you have something like

    group :development do
      gem 'spring'
    

    You can promote it above the block.