NameError: uninitialized constant Sprockets::Engines

665 Views Asked by At

rails 5.0 (upgrading from 4.2 to 5.0) ruby 2.6.4, rspec 3.6

I'm upgrading a rails app from rails 4.2 up to 5.2. Currently trying to get to 5.0. I'm fixing deprecations and tests, but currently stuck on this error when running my spec tests. Listing one spec here to save space, but they all fail with the same error (below).

I've read a ton of threads similar to this, but no real answers on how to fix it - or my issue.

tests:

ruby-2.6.4  git:(upstream ⚡ rails5) 5M
jdc44@dev:~/apps/sha_student_services$ bx rspec spec/controllers/manage/course_reports_controller_spec.rb 

DEPRECATION WARNING: The factory_girl gem is deprecated. Please upgrade to factory_bot. See https://github.com/thoughtbot/factory_bot/blob/v4.9.0/UPGRADE_FROM_FACTORY_GIRL.md for further instructions. (called from require at /usr/local/rvm/rubies/ruby-2.6.4/lib/ruby/site_ruby/2.6.0/bundler/runtime.rb:81)

An error occurred while loading ./spec/controllers/manage/course_reports_controller_spec.rb.
Failure/Error: require File.expand_path("../../config/environment", __FILE__)

NameError:
  uninitialized constant Sprockets::Engines
# ./vendor/bundle/ruby/2.6.0/gems/less-rails-2.6.0/lib/less/rails/railtie.rb:17:in `block in <class:Railtie>'
# ./vendor/bundle/ruby/2.6.0/gems/activesupport-5.0.7.2/lib/active_support/lazy_load_hooks.rb:67:in `block in execute_hook'
# ./vendor/bundle/ruby/2.6.0/gems/activesupport-5.0.7.2/lib/active_support/lazy_load_hooks.rb:60:in `with_execution_control'
# ./vendor/bundle/ruby/2.6.0/gems/activesupport-5.0.7.2/lib/active_support/lazy_load_hooks.rb:65:in `execute_hook'
# ./vendor/bundle/ruby/2.6.0/gems/activesupport-5.0.7.2/lib/active_support/lazy_load_hooks.rb:50:in `block in run_load_hooks'
# ./vendor/bundle/ruby/2.6.0/gems/activesupport-5.0.7.2/lib/active_support/lazy_load_hooks.rb:49:in `each'
# ./vendor/bundle/ruby/2.6.0/gems/activesupport-5.0.7.2/lib/active_support/lazy_load_hooks.rb:49:in `run_load_hooks'
# ./vendor/bundle/ruby/2.6.0/gems/railties-5.0.7.2/lib/rails/application/bootstrap.rb:78:in `block in <module:Bootstrap>'
# ./vendor/bundle/ruby/2.6.0/gems/railties-5.0.7.2/lib/rails/initializable.rb:30:in `instance_exec'
# ./vendor/bundle/ruby/2.6.0/gems/railties-5.0.7.2/lib/rails/initializable.rb:30:in `run'
# ./vendor/bundle/ruby/2.6.0/gems/railties-5.0.7.2/lib/rails/initializable.rb:55:in `block in run_initializers'
# ./vendor/bundle/ruby/2.6.0/gems/railties-5.0.7.2/lib/rails/initializable.rb:54:in `run_initializers'
# ./vendor/bundle/ruby/2.6.0/gems/railties-5.0.7.2/lib/rails/application.rb:352:in `initialize!'
# ./vendor/bundle/ruby/2.6.0/gems/railties-5.0.7.2/lib/rails/railtie.rb:193:in `public_send'
# ./vendor/bundle/ruby/2.6.0/gems/railties-5.0.7.2/lib/rails/railtie.rb:193:in `method_missing'
# ./config/environment.rb:8:in `<top (required)>'
# ./spec/spec_helper.rb:8:in `require'
# ./spec/spec_helper.rb:8:in `<top (required)>'
# ./spec/controllers/manage/course_reports_controller_spec.rb:1:in `require'
# ./spec/controllers/manage/course_reports_controller_spec.rb:1:in `<top (required)>'
No examples found.


Finished in 0.00039 seconds (files took 3.49 seconds to load)
0 examples, 0 failures, 1 error occurred outside of examples

The FactoryGirl deprecation is going to be upgraded to FactoryBot, I'm just not there yet.

In the above output, I see these errors/clues:

# ./spec/controllers/manage/course_reports_controller_spec.rb:1:in `<top (required)>'

In that file line 1 is require 'spec_helper'

# ./spec/spec_helper.rb:8:in `<top (required)>'

In that file line 8 is: require File.expand_path("../../config/environment", __FILE__)

# ./config/environment.rb:8:in `<top (required)>'

In that file line 8 is: StudentServices::Application.initialize!

Gemfile:
...
gem 'sprockets'
gem 'sass-rails'
...
Gemfile.lock:
...
sprockets (4.0.0) 
sprockets-rails (3.2.1)
sass-rails (6.0.0)
...

I listed the sass-rails, cuz I saw a post on stackoverflow that mentioned this problem was resolved in sass-rails. rails 4 - rake command shows deprecation warning everytime I run the rake db:migrate command These gems are at their most current versions, but the problem still exists.

I did play with lowering sprockets down to 3.7.0, that gives me a different error but still involves sprockets:

ruby-2.6.4  git:(upstream ⚡ rails5) 5M
jdc44@dev:~/apps/sha_student_services$ bx rspec spec/controllers/manage/course_reports_controller_spec.rb 

/home/STATLER/jdc44/apps/sha_student_services/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.0/lib/sprockets/digest_utils.rb:47: warning: constant ::Fixnum is deprecated

/home/STATLER/jdc44/apps/sha_student_services/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.0/lib/sprockets/digest_utils.rb:51: warning: constant ::Bignum is deprecated

/home/STATLER/jdc44/apps/sha_student_services/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.0/lib/sprockets/processor_utils.rb:110: warning: constant ::Fixnum is deprecated

/home/STATLER/jdc44/apps/sha_student_services/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.0/lib/sprockets/processor_utils.rb:111: warning: constant ::Bignum is deprecated

DEPRECATION WARNING: The factory_girl gem is deprecated. Please upgrade to factory_bot. See https://github.com/thoughtbot/factory_bot/blob/v4.9.0/UPGRADE_FROM_FACTORY_GIRL.md for further instructions. (called from require at /usr/local/rvm/rubies/ruby-2.6.4/lib/ruby/site_ruby/2.6.0/bundler/runtime.rb:81)

DEPRECATION WARNING: Sprockets method `register_engine` is deprecated.
Please register a mime type using `register_mime_type` then
use `register_compressor` or `register_transformer`.
https://github.com/rails/sprockets/blob/master/guides/extending_sprockets.md#supporting-all-versions-of-sprockets-in-processors

 (called from block in <class:Railtie> at /home/STATLER/jdc44/apps/sha_student_services/vendor/bundle/ruby/2.6.0/gems/less-rails-2.6.0/lib/less/rails/railtie.rb:18)

An error occurred while loading ./spec/controllers/manage/course_reports_controller_spec.rb.
Failure/Error: require File.expand_path("../../config/environment", __FILE__)

NoMethodError:
  undefined method `register_preprocessor' for nil:NilClass
# ./vendor/bundle/ruby/2.6.0/gems/less-rails-2.6.0/lib/less/rails/railtie.rb:22:in `block in <class:Railtie>'
# ./vendor/bundle/ruby/2.6.0/gems/railties-5.0.7.2/lib/rails/initializable.rb:30:in `instance_exec'
# ./vendor/bundle/ruby/2.6.0/gems/railties-5.0.7.2/lib/rails/initializable.rb:30:in `run'
# ./vendor/bundle/ruby/2.6.0/gems/railties-5.0.7.2/lib/rails/initializable.rb:55:in `block in run_initializers'
# ./vendor/bundle/ruby/2.6.0/gems/railties-5.0.7.2/lib/rails/initializable.rb:54:in `run_initializers'
# ./vendor/bundle/ruby/2.6.0/gems/railties-5.0.7.2/lib/rails/application.rb:352:in `initialize!'
# ./vendor/bundle/ruby/2.6.0/gems/railties-5.0.7.2/lib/rails/railtie.rb:193:in `public_send'
# ./vendor/bundle/ruby/2.6.0/gems/railties-5.0.7.2/lib/rails/railtie.rb:193:in `method_missing'
# ./config/environment.rb:8:in `<top (required)>'
# ./spec/spec_helper.rb:8:in `require'
# ./spec/spec_helper.rb:8:in `<top (required)>'
# ./spec/controllers/manage/course_reports_controller_spec.rb:1:in `require'
# ./spec/controllers/manage/course_reports_controller_spec.rb:1:in `<top (required)>'
No examples found.


Finished in 0.00053 seconds (files took 3.83 seconds to load)
0 examples, 0 failures, 1 error occurred outside of examples

In this output, there is a url to github that talks about this deprecation. I wasn't sure what how to apply that to my app to resolve this OR if that is even the problem.

I'm hoping someone may know more about what is causing this sprockets error and how to fix it.

I'm happy to edit this post and add more content if needed.

Thanks for looking at this.

jc

0

There are 0 best solutions below