Unable to duplicate NilClass on asset rails: precompile

When I try to precompile my assets, I get the following error. This is a full exit trace:

RAILS_ENV=production bundle exec rake assets:precompile --trace ** Invoke assets:precompile (first_time) ** Invoke assets:environment (first_time) ** Execute assets:environment ** Invoke environment (first_time) ** Execute environment rake aborted! TypeError: can't dup NilClass /var/lib/gems/2.3.0/gems/redis-activesupport-5.0.3/lib/active_support/cache/redis_store.rb:38:in `dup' /var/lib/gems/2.3.0/gems/redis-activesupport-5.0.3/lib/active_support/cache/redis_store.rb:38:in `map' /var/lib/gems/2.3.0/gems/redis-activesupport-5.0.3/lib/active_support/cache/redis_store.rb:38:in `initialize' /var/lib/gems/2.3.0/gems/activesupport-5.0.5/lib/active_support/cache.rb:60:in `new' /var/lib/gems/2.3.0/gems/activesupport-5.0.5/lib/active_support/cache.rb:60:in `lookup_store' /var/lib/gems/2.3.0/gems/railties-5.0.5/lib/rails/application/bootstrap.rb:64:in `block in <module:Bootstrap>' /var/lib/gems/2.3.0/gems/railties-5.0.5/lib/rails/initializable.rb:30:in `instance_exec' /var/lib/gems/2.3.0/gems/railties-5.0.5/lib/rails/initializable.rb:30:in `run' /var/lib/gems/2.3.0/gems/railties-5.0.5/lib/rails/initializable.rb:55:in `block in run_initializers' /usr/lib/ruby/2.3.0/tsort.rb:228:in `block in tsort_each' /usr/lib/ruby/2.3.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component' /usr/lib/ruby/2.3.0/tsort.rb:431:in `each_strongly_connected_component_from' /usr/lib/ruby/2.3.0/tsort.rb:349:in `block in each_strongly_connected_component' /usr/lib/ruby/2.3.0/tsort.rb:347:in `each' /usr/lib/ruby/2.3.0/tsort.rb:347:in `call' /usr/lib/ruby/2.3.0/tsort.rb:347:in `each_strongly_connected_component' /usr/lib/ruby/2.3.0/tsort.rb:226:in `tsort_each' /usr/lib/ruby/2.3.0/tsort.rb:205:in `tsort_each' /var/lib/gems/2.3.0/gems/railties-5.0.5/lib/rails/initializable.rb:54:in `run_initializers' /var/lib/gems/2.3.0/gems/railties-5.0.5/lib/rails/application.rb:352:in `initialize!' /home/alex/Dev/livingrecipe/config/environment.rb:5:in `<top (required)>' /var/lib/gems/2.3.0/gems/activesupport-5.0.5/lib/active_support/dependencies.rb:293:in `require' /var/lib/gems/2.3.0/gems/activesupport-5.0.5/lib/active_support/dependencies.rb:293:in `block in require' /var/lib/gems/2.3.0/gems/activesupport-5.0.5/lib/active_support/dependencies.rb:259:in `load_dependency' /var/lib/gems/2.3.0/gems/activesupport-5.0.5/lib/active_support/dependencies.rb:293:in `require' /var/lib/gems/2.3.0/gems/railties-5.0.5/lib/rails/application.rb:328:in `require_environment!' /var/lib/gems/2.3.0/gems/railties-5.0.5/lib/rails/application.rb:448:in `block in run_tasks_blocks' /var/lib/gems/2.3.0/gems/rake-12.0.0/lib/rake/task.rb:250:in `block in execute' /var/lib/gems/2.3.0/gems/rake-12.0.0/lib/rake/task.rb:250:in `each' /var/lib/gems/2.3.0/gems/rake-12.0.0/lib/rake/task.rb:250:in `execute' /var/lib/gems/2.3.0/gems/rake-12.0.0/lib/rake/task.rb:194:in `block in invoke_with_call_chain' /usr/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize' /var/lib/gems/2.3.0/gems/rake-12.0.0/lib/rake/task.rb:187:in `invoke_with_call_chain' /var/lib/gems/2.3.0/gems/rake-12.0.0/lib/rake/task.rb:180:in `invoke' /var/lib/gems/2.3.0/gems/sprockets-rails-3.2.0/lib/sprockets/rails/task.rb:62:in `block (2 levels) in define' /var/lib/gems/2.3.0/gems/rake-12.0.0/lib/rake/task.rb:250:in `block in execute' /var/lib/gems/2.3.0/gems/rake-12.0.0/lib/rake/task.rb:250:in `each' /var/lib/gems/2.3.0/gems/rake-12.0.0/lib/rake/task.rb:250:in `execute' /var/lib/gems/2.3.0/gems/rake-12.0.0/lib/rake/task.rb:194:in `block in invoke_with_call_chain' /usr/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize' /var/lib/gems/2.3.0/gems/rake-12.0.0/lib/rake/task.rb:187:in `invoke_with_call_chain' /var/lib/gems/2.3.0/gems/rake-12.0.0/lib/rake/task.rb:216:in `block in invoke_prerequisites' /var/lib/gems/2.3.0/gems/rake-12.0.0/lib/rake/task.rb:214:in `each' /var/lib/gems/2.3.0/gems/rake-12.0.0/lib/rake/task.rb:214:in `invoke_prerequisites' /var/lib/gems/2.3.0/gems/rake-12.0.0/lib/rake/task.rb:193:in `block in invoke_with_call_chain' /usr/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize' /var/lib/gems/2.3.0/gems/rake-12.0.0/lib/rake/task.rb:187:in `invoke_with_call_chain' /var/lib/gems/2.3.0/gems/rake-12.0.0/lib/rake/task.rb:180:in `invoke' /var/lib/gems/2.3.0/gems/rake-12.0.0/lib/rake/application.rb:152:in `invoke_task' /var/lib/gems/2.3.0/gems/rake-12.0.0/lib/rake/application.rb:108:in `block (2 levels) in top_level' /var/lib/gems/2.3.0/gems/rake-12.0.0/lib/rake/application.rb:108:in `each' /var/lib/gems/2.3.0/gems/rake-12.0.0/lib/rake/application.rb:108:in `block in top_level' /var/lib/gems/2.3.0/gems/rake-12.0.0/lib/rake/application.rb:117:in `run_with_threads' /var/lib/gems/2.3.0/gems/rake-12.0.0/lib/rake/application.rb:102:in `top_level' /var/lib/gems/2.3.0/gems/rake-12.0.0/lib/rake/application.rb:80:in `block in run' /var/lib/gems/2.3.0/gems/rake-12.0.0/lib/rake/application.rb:178:in `standard_exception_handling' /var/lib/gems/2.3.0/gems/rake-12.0.0/lib/rake/application.rb:77:in `run' /var/lib/gems/2.3.0/gems/rake-12.0.0/exe/rake:27:in `<top (required)>' /usr/local/bin/rake:23:in `load' /usr/local/bin/rake:23:in `<main>' 

So, unfortunately, I can’t understand what the error indicates, since none of these codes is my material, and basically the trace consists of the default gem code. The only thing I can see that I added is the homing, but the same thing happens even if I do it.

+7
ruby ruby-on-rails
source share
4 answers

So I'm not sure what the problem is, but I updated the ruby, rails and all my gems, and this got rid of this problem. Therefore, thinking that this is a compatibility issue with version mismatch somewhere

0
source share

It looks like you have the wrong redis connection (or setup)

Debug it:

1) Debug reconnection with rails console. Using Redis from Your Application

 >> require 'rubygems' => false >> require 'redis' => true >> r = Redis.new => #<Redis client v2.2.1 connected to redis://127.0.0.1:6379/0 (Redis v2.3.8)> >> r.ping => "PONG" >> r.set('foo','bar') => "OK" >> r.get('foo') => "bar" 

2) Debugging RedisStore

 RedisStore.new("localhost:6379/0/cache", expires_in: 90.minutes) 

3) If the command passes, configure this configuration for your application as described in gem redis-rails

 # config/application.rb config.cache_store = :redis_store, "redis://localhost:6379/0/cache", { expires_in: 90.minutes } 

4) Play with the configuration a bit to establish a successful connection with redis (And do not forget about the various configurations of the production environment !!!)

5) Commit changes, redistribute.

0
source share

You are trying to compile assets in a production environment, but you are also on your development computer. Are you sure you set up your production environment in all of your configuration files? Look in config / cable.yml and config / redis.yml if they exist.

Alternatively, a good way to compile assets in a development environment is:

 RAILS_ENV=development bundle exec rake assets:precompile 

However, after that, Rails will use these compiled assets in development instead of your assets in the application / assets. In the end, you'll also want to run RAILS_ENV=development bundle exec rake assets:clobber or rm -rf public/assets to clear the development environment of these compiled assets.

0
source share

from the sent stack trace, it looks like you should check the value

 config.cache_store 

it is most likely empty:

https://github.com/rails/rails/blob/87eb1a26da0b1385af07a8347dcfd32998a614ee/railties/lib/rails/application/bootstrap.rb#L67

0
source share

All Articles