Heroku doesn't recognize 'spring' gem, even though it's listed in the Gemfile

I've deployed to Heroku in the past with very few issues. Today I created a very basic app (literally just the default 'new' with an updated gemfile) and pushed it up to Heroku.

However, Heroku doesn't recognize the 'spring' gem, even though it's listed in the Gemfile. It's causing my app to crash. And before it's asked, yes I have run bundle install and bundle update after updating the Gemfile.

Gemfile (Literally copy-pasted from RoR Tutorial):

source 'https://rubygems.org'

gem 'rails',        '4.2.2'
gem 'sass-rails',   '5.0.2'
gem 'uglifier',     '2.5.3'
gem 'coffee-rails', '4.1.0'
gem 'jquery-rails', '4.0.3'
gem 'turbolinks',   '2.3.0'
gem 'jbuilder',     '2.2.3'
gem 'sdoc',         '0.4.0', group: :doc

group :development, :test do
  gem 'sqlite3',     '1.3.9'
  gem 'byebug',      '3.4.0'
  gem 'web-console', '2.0.0.beta3'
  gem 'spring',      '1.1.3'
end

group :test do
  gem 'minitest-reporters', '1.0.5'
  gem 'mini_backtrace',     '0.1.3'
  gem 'guard-minitest',     '2.3.1'
end

group :production do
  gem 'pg',             '0.17.1'
  gem 'rails_12factor', '0.0.2'
end

Error message after running heroku run rails console:

Running rails console on pure-falls-2221... up, run.6936
/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/rubygems/dependency.rb:296:in `to_specs': Could not find 'spring' (= 1.1.3) among 59 total gem(s) (Gem::LoadError)
    from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/rubygems/dependency.rb:307:in `to_spec'
    from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/rubygems/core_ext/kernel_gem.rb:47:in `gem'
    from /app/bin/spring:12:in `<top (required)>'
    from /app/bin/rails:4:in `load'
    from /app/bin/rails:4:in `<main>'

Heroku Logs:

2015-11-17T02:00:32.426615+00:00 heroku[slug-compiler]: Slug compilation started
2015-11-17T02:00:32.426624+00:00 heroku[slug-compiler]: Slug compilation finished
2015-11-17T02:00:35.179885+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 29889 -e production`
2015-11-17T02:00:37.945522+00:00 app[web.1]:    from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/rubygems/dependency.rb:307:in `to_spec'
2015-11-17T02:00:37.945526+00:00 app[web.1]:    from bin/rails:4:in `<main>'
2015-11-17T02:00:37.945524+00:00 app[web.1]:    from /app/bin/spring:12:in `<top (required)>'
2015-11-17T02:00:37.945525+00:00 app[web.1]:    from bin/rails:4:in `load'
2015-11-17T02:00:37.945523+00:00 app[web.1]:    from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/rubygems/core_ext/kernel_gem.rb:47:in `gem'
2015-11-17T02:00:37.945512+00:00 app[web.1]: /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/rubygems/dependency.rb:296:in `to_specs': Could not find 'spring' (= 1.1.3) among 59 total gem(s) (Gem::LoadError)
2015-11-17T02:00:38.782080+00:00 heroku[web.1]: Process exited with status 1
2015-11-17T02:00:40.980407+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 7751 -e production`
2015-11-17T02:00:38.801178+00:00 heroku[web.1]: State changed from starting to crashed
2015-11-17T02:00:38.801178+00:00 heroku[web.1]: State changed from crashed to starting
2015-11-17T02:00:43.123615+00:00 app[web.1]: /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/rubygems/dependency.rb:296:in `to_specs': Could not find 'spring' (= 1.1.3) among 59 total gem(s) (Gem::LoadError)
2015-11-17T02:00:43.123626+00:00 app[web.1]:    from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/rubygems/dependency.rb:307:in `to_spec'
2015-11-17T02:00:43.123629+00:00 app[web.1]:    from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/rubygems/core_ext/kernel_gem.rb:47:in `gem'
2015-11-17T02:00:43.123630+00:00 app[web.1]:    from /app/bin/spring:12:in `<top (required)>'
2015-11-17T02:00:43.123630+00:00 app[web.1]:    from bin/rails:4:in `load'
2015-11-17T02:00:43.123631+00:00 app[web.1]:    from bin/rails:4:in `<main>'
2015-11-17T02:00:44.203452+00:00 heroku[web.1]: State changed from starting to crashed
2015-11-17T02:01:05.291898+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=pure-falls-2221.herokuapp.com request_id=adc1ccb9-cd90-45fd-b179-ef680f936c2f fwd="125.140.58.57" dyno= connect= service= status=503 bytes=
2015-11-17T02:01:06.107852+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=pure-falls-2221.herokuapp.com request_id=a92abeed-9b09-4ff8-b535-bac178eb454b fwd="125.140.58.57" dyno= connect= service= status=503 bytes=
2015-11-17T02:01:19.376119+00:00 heroku[api]: Starting process with command `rails console` by chrabyrd@gmail.com
2015-11-17T02:01:21.779621+00:00 heroku[run.6936]: Awaiting client
2015-11-17T02:01:21.797009+00:00 heroku[run.6936]: Starting process with command `rails console`
2015-11-17T02:01:22.153107+00:00 heroku[run.6936]: State changed from starting to up
2015-11-17T02:01:24.185437+00:00 heroku[run.6936]: State changed from up to complete
2015-11-17T02:01:24.169704+00:00 heroku[run.6936]: Process exited with status 1

Any help would be greatly appreciated!

Answers


You have the gem in the development group. If you take it out of that group and put it in the main group, do another bundle install, add that to the repo and redeploy, I presume it will all work just fine.


I am new to Rails and going through the tutorial as well. I had this same issue. Here is the answer after much looking and discussion with an experienced Rails dev.

Look in the bin/rails file at line 4 according to your log file: (here is that code. Line 4 is where the error is happening.)

#!/usr/bin/env ruby
begin
  spring_bin_path = File.expand_path('../spring', __FILE__)
  load spring_bin_path
rescue LoadError => e
  raise unless e.message.end_with? spring_bin_path, 'spring/binstub'
end
APP_PATH = File.expand_path('../../config/application', __FILE__)
require_relative '../config/boot'
require 'rails/commands'

If you remove line 6, then the error will not be raised and spring will not be loaded. This is what the previous versions of the bin/rails code did and all worked fine. I don't know if it's Rails or Cloud9 or what is generating this code but something changed in the last couple days, no doubt.

NOTE: Be sure to leave the spring gem in the development group of gemfile. I would not move the spring gem to the main group in the gemfile since Spring is not supposed to run on production no matter what from my limited knowledge.

Hope this helps.


I put in a ticket with the spring guys

https://github.com/rails/spring/issues/450

I am suspecting this has to do with the spring gem release version 1.4.4


Until the Spring team come up with a better solution I have patched bin/rails and set a Heroku environment variable to avoid loading Spring in production:

heroku config:set DISABLE_SPRING=1

bin/rails:

#!/usr/bin/env ruby
unless ENV["DISABLE_SPRING"]
  begin
    spring_bin_path = File.expand_path('../spring', __FILE__)
    load spring_bin_path
  rescue LoadError => e
    raise unless e.message.end_with? spring_bin_path, 'spring/binstub'
  end
end
APP_PATH = File.expand_path('../../config/application',  __FILE__)
require_relative '../config/boot'
require 'rails/commands'

DISABLE_SPRING is the recommended environment variable as per their documentation.


The latest version of spring is 1.4.2. You may want to do spring as that version instead of the older version.


Need Your Help

asp.net MVC4 Access to a variable from a view in another view (ActionLink)

c# asp.net-mvc-4 view actionlink

i have the following problem with my Forestry Management Applpication:

Should protected attributes always be banned?

oop protected

I seldom use inheritance, but when I do, I never use protected attributes because I think it breaks the encapsulation of the inherited classes.