Skip to content

Spring error running rails console specifying production envionment in rails 6.1 #41301

@jcoyne

Description

@jcoyne

Steps to reproduce

In rails 6.0, I was able to run the production console by doing:

$ bin/rails console -e production

But after upgrading to Rails 6.1 doing this invocation without first setting RAILS_ENV causes a problem trying to load spring.

Traceback (most recent call last):
	7: from bin/rails:2:in `<main>'
	6: from bin/rails:2:in `load'
	5: from /opt/app/h2/happy-heron/releases/20210202025603/bin/spring:5:in `<top (required)>'
	4: from /opt/app/h2/happy-heron/releases/20210202025603/bin/spring:5:in `tap'
	3: from /opt/app/h2/happy-heron/releases/20210202025603/bin/spring:7:in `block in <top (required)>'
	2: from /usr/local/rvm/rubies/ruby-2.7.1/lib/ruby/site_ruby/2.7.0/rubygems/core_ext/kernel_gem.rb:62:in `gem'
	1: from /usr/local/rvm/rubies/ruby-2.7.1/lib/ruby/site_ruby/2.7.0/rubygems/dependency.rb:319:in `to_spec'
/usr/local/rvm/rubies/ruby-2.7.1/lib/ruby/site_ruby/2.7.0/rubygems/dependency.rb:307:in `to_specs': Could not find 'spring' (= 2.1.1) among 349 total gem(s) (Gem::MissingSpecError)
Checked in 'GEM_PATH=/opt/app/h2/happy-heron/shared/bundle/ruby/2.7.0:/usr/local/rvm/gems/ruby-2.7.1:/usr/local/rvm/rubies/ruby-2.7.1/lib/ruby/gems/2.7.0' , execute `gem env` for more information

I do not have spring installed on this machine since I used bundle config set --local without development:test

The help message indicates this is should be possible to do:

22:35 $ bin/rails console --help
Running via Spring preloader in process 49587
Usage:
  rails console [options]

Options:
  -e, [--environment=ENVIRONMENT]  # Specifies the environment to run this console under (test/development/production).
  -s, [--sandbox], [--no-sandbox]  # Rollback database modifications on exit.

Expected behavior

It should load the console in production mode

Actual behavior

Error because Spring is missing.

System configuration

Rails version:
6.1.0
Ruby version:
2.7.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions