Rails TypeError:无法修改不可变索引

时间:2016-01-12 15:52:45

标签: ruby-on-rails heroku

我很难被这个人困住。看起来这是我在尝试推送到Heroku时遇到的链轮错误。自从我上一次推送以来,我唯一做过的就是添加到发条宝石以及相关的lib/clock.rblib/clock_events_worker.rb文件中。

我应该检查什么想法?我还没碰过任何CSS。

remote: -----> Preparing app for Rails asset pipeline
remote:        Running: rake assets:precompile
remote:        rake aborted!
remote:        TypeError: can't modify immutable index
remote:        /tmp/build_76f6fceeb8ba577abcf815781a45737e/vendor/bundle/ruby/2.2.0/gems/sprockets-2.12.4/lib/sprockets/index.rb:81:in `expire_index!'
remote:        /tmp/build_76f6fceeb8ba577abcf815781a45737e/vendor/bundle/ruby/2.2.0/gems/sprockets-2.12.4/lib/sprockets/base.rb:175:in `register_preprocessor'
remote:        /tmp/build_76f6fceeb8ba577abcf815781a45737e/vendor/bundle/ruby/2.2.0/gems/js-routes-1.2.2/lib/js_routes/engine.rb:11:in `block in <class:Engine>'
remote:        /tmp/build_76f6fceeb8ba577abcf815781a45737e/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.0/lib/active_support/lazy_load_hooks.rb:36:in `call'
remote:        /tmp/build_76f6fceeb8ba577abcf815781a45737e/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.0/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
remote:        /tmp/build_76f6fceeb8ba577abcf815781a45737e/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.0/lib/active_support/lazy_load_hooks.rb:45:in `block in run_load_hooks'
remote:        /tmp/build_76f6fceeb8ba577abcf815781a45737e/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.0/lib/active_support/lazy_load_hooks.rb:44:in `each'
remote:        /tmp/build_76f6fceeb8ba577abcf815781a45737e/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.0/lib/active_support/lazy_load_hooks.rb:44:in `run_load_hooks'
remote:        /tmp/build_76f6fceeb8ba577abcf815781a45737e/vendor/bundle/ruby/2.2.0/gems/railties-4.2.0/lib/rails/application/finisher.rb:62:in `block in <module:Finisher>'
remote:        /tmp/build_76f6fceeb8ba577abcf815781a45737e/vendor/bundle/ruby/2.2.0/gems/railties-4.2.0/lib/rails/initializable.rb:30:in `instance_exec'
remote:        /tmp/build_76f6fceeb8ba577abcf815781a45737e/vendor/bundle/ruby/2.2.0/gems/railties-4.2.0/lib/rails/initializable.rb:30:in `run'
remote:        /tmp/build_76f6fceeb8ba577abcf815781a45737e/vendor/bundle/ruby/2.2.0/gems/railties-4.2.0/lib/rails/initializable.rb:55:in `block in run_initializers'
remote:        /tmp/build_76f6fceeb8ba577abcf815781a45737e/vendor/bundle/ruby/2.2.0/gems/railties-4.2.0/lib/rails/initializable.rb:54:in `run_initializers'
remote:        /tmp/build_76f6fceeb8ba577abcf815781a45737e/vendor/bundle/ruby/2.2.0/gems/railties-4.2.0/lib/rails/application.rb:352:in `initialize!'
remote:        /tmp/build_76f6fceeb8ba577abcf815781a45737e/vendor/bundle/ruby/2.2.0/gems/railties-4.2.0/lib/rails/railtie.rb:194:in `public_send'
remote:        /tmp/build_76f6fceeb8ba577abcf815781a45737e/vendor/bundle/ruby/2.2.0/gems/railties-4.2.0/lib/rails/railtie.rb:194:in `method_missing'
remote:        /tmp/build_76f6fceeb8ba577abcf815781a45737e/config/environment.rb:5:in `<top (required)>'
remote:        /tmp/build_76f6fceeb8ba577abcf815781a45737e/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `require'
remote:        /tmp/build_76f6fceeb8ba577abcf815781a45737e/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `block in require'
remote:        /tmp/build_76f6fceeb8ba577abcf815781a45737e/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:240:in `load_dependency'
remote:        /tmp/build_76f6fceeb8ba577abcf815781a45737e/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `require'
remote:        /tmp/build_76f6fceeb8ba577abcf815781a45737e/vendor/bundle/ruby/2.2.0/gems/railties-4.2.0/lib/rails/application.rb:328:in `require_environment!'
remote:        /tmp/build_76f6fceeb8ba577abcf815781a45737e/vendor/bundle/ruby/2.2.0/gems/railties-4.2.0/lib/rails/application.rb:443:in `block in run_tasks_blocks'
remote:        /tmp/build_76f6fceeb8ba577abcf815781a45737e/vendor/bundle/ruby/2.2.0/gems/sprockets-rails-2.3.3/lib/sprockets/rails/task.rb:64:in `block (2 levels) in define'
remote:        Tasks: TOP => environment
remote:        (See full trace by running task with --trace)
remote:  !
remote:  !     Precompiling assets failed.
remote:  !
remote: 
remote:  !     Push rejected, failed to compile Ruby app
remote: 
remote: Verifying deploy...
remote: 

3 个答案:

答案 0 :(得分:0)

在您的文件environments/development.rbenvironments/production.rb等中,确保设置了以下值:

config.assets.debug = false
config.assets.compress = true
config.assets.digest = true

答案 1 :(得分:0)

解决方案似乎是在我的gemfile中添加sprockets。之后推得很好。

gem 'sprockets', '~> 3.0'

答案 2 :(得分:0)

我遇到了这个问题,因为我正在做一些生产测试,却忘记了使用RAILS_ENV=development将环境重新设置为开发状态。

顺便说一句,将本地环境设置为生产环境是不明智的做法。我只需要prod来执行预编译器,就可以这样做:

RAILS_ENV=production bundle exec rake assets:precompile

针对不影响环境变量的特定环境执行命令。