jwhitley / requirejs-rails

RequireJS support for your Rails 3 or 4 application
MIT License
592 stars 201 forks source link

TypeError: can't modify immutable index #185

Closed Rakoth closed 10 years ago

Rakoth commented 10 years ago

In rails 3.2 assets precompilation task failing with error message: "TypeError: can't modify immutable index". Here is example app for this problem: https://github.com/Rakoth/requirejs-rails-test-app I commented on #176 which introduce this error, but no activity there, so I decided create new issue.

carsomyr commented 10 years ago

@Rakoth Hey, thanks! Stuff like this goes a long way towards helping me fix this problem.

rmdydo commented 10 years ago

+1 Im getting this same issue with rails 4.0 when deploying to heroku.

carsomyr commented 10 years ago

@Rakoth @rmdydo Try my fork?

rmdydo commented 10 years ago

That did not work for me, however config.cache_classes does seem to be the issue. Originally it was set to true but when changing that to false, precomplication was successful. Seems like the issue is with config.cache_classes = false in engine.rb being overidden by the main app config?

carsomyr commented 10 years ago

@rmdydo Please paste a dump pf your Gemfile.lock.

rmdydo commented 10 years ago

https://gist.github.com/rmdydo/48fbcc4a99398b0be8d3

carsomyr commented 10 years ago

@rmdydo It looks like requirejs-rails is pointing to aar0nTw/requirejs-rails. I'm assuming that you tried out my fork?

carsomyr commented 10 years ago

@rmdydo Also, could you try bundle exec rake assets:precompile locally? You reported the problem as manifesting when deploying to Heroku.

carsomyr commented 10 years ago

@Rakoth FYI, your requirejs-rails-test-app project compiles fine after the changes. Please confirm.

Rakoth commented 10 years ago

@carsomyr confirmed, its work!

carsomyr commented 10 years ago

@rmdydo Let me know if you manage to reproduce the problem with a minimal set of gems while locally running bundle exec rake assets:precompile.

rmdydo commented 10 years ago

I cloned Rakoth's test app and am still getting while running bundle exec rake assets:precompile

GROUPS=assets rake aborted! Asset compilation with node failed with error:

/home/rdydo/.rvm/gems/ruby-2.1.2/bundler/gems/requirejs-rails-03aab50dd103/lib/tasks/requirejs-rails_tasks.rake:139:in block (3 levels) in <top (required)>' Tasks: TOP => requirejs:precompile:all => requirejs:precompile:run_rjs (See full trace by running task with --trace) rake aborted! Command failed with status (1): [/home/rdydo/.rvm/rubies/ruby-2.1.2/bin/rub...] /home/rdydo/.rvm/gems/ruby-2.1.2/bundler/gems/requirejs-rails-03aab50dd103/lib/tasks/requirejs-rails_tasks.rake:19:inruby_rake_task' /home/rdydo/.rvm/gems/ruby-2.1.2/bundler/gems/requirejs-rails-03aab50dd103/lib/tasks/requirejs-rails_tasks.rake:86:in `block (3 levels) in <top (required)>' Tasks: TOP => assets:precompile => requirejs:precompile:external (See full trace by running task with --trace)

carsomyr commented 10 years ago

@rmdydo You have to bundle update to pull down the latest changes on requirejs-rails master.

rmdydo commented 10 years ago

The fix does work for me on Rakoths test app using my orignal gemfile with both rails 3.2 and 4.0 but this was after commenting out the asset_sync gem, which would fail due to it not being configured. In my original project I do still get the immutable index exception duing precompile and the only gem file difference here is the asset_sync gem. Im guessing asset_sync is the culprit?

carsomyr commented 10 years ago

@rmdydo Make sure that config.cache_classes doesn't appear in your asset_sync.rb file.

carsomyr commented 10 years ago

@rmdydo Any luck getting it to work? What if you include asset_sync in your Gemfile but take no steps to configure it? I'm asking because you could try adding in one configuration setting after another, until one breaks precompilation.

rmdydo commented 10 years ago

No luck so far. I dont think it is asset_sync because I was able to get Rakoth's test app to successfully deploy with asset_sync configured. I also use ActiveAdmin and looked into this because that still uses sproket directives for js but after completely removing that I was still not able to successfully precompile. Im guessing its something specific about my app config or a gem that I'm using that is causing the issue. I plan to continue to rip out stuff until it works.

carsomyr commented 10 years ago

@rmdydo How about this idea: Print some info right before these lines of code. If you catch sprockets-rails freezing the environment before requirejs-rails gets to run, that's the reason.