importmap-rails: NoMethodError: private method `importmap=' called

I’m updating importmap-rails from 0.6.1 to 0.7.6 and I get the following error:

NoMethodError: private method `importmap=' called for #<XXXX::Application:0x000056001ecded98>
/home/runner/work/xxxx/xxxx/vendor/bundle/ruby/2.6.0/gems/importmap-rails-0.7.6/lib/importmap/engine.rb:14:in `block in <class:Engine>'
  • importmap-rails 0.7.6
  • stimulus-rails 0.6.0
  • turbo-rails 0.8.1
  • rails 6.1.4.1
# config/importmap.rb

pin 'bootstrap', to: 'https://cdn.skypack.dev/bootstrap'
pin '@hotwired/turbo-rails', to: 'turbo.js'
pin '@hotwired/stimulus', to: 'stimulus.js'
pin '@hotwired/stimulus-autoloader', to: 'stimulus-autoloader.js'
pin '@hotwired/stimulus-importmap-autoloader', to: 'stimulus-importmap-autoloader.js'
pin '@rails/activestorage', to: 'https://cdn.skypack.dev/@rails/activestorage'
pin '@rails/actioncable', to: 'https://cdn.skypack.dev/@rails/actioncable'
pin 'trix', to: 'https://cdn.skypack.dev/trix'
pin '@rails/actiontext', to: 'https://cdn.skypack.dev/@rails/actiontext'

pin_all_from 'app/assets/javascripts/channels', under: 'channels'
pin_all_from 'app/assets/javascripts/controllers', under: 'controllers'

pin 'application'

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (6 by maintainers)

Commits related to this issue

Most upvoted comments

@javierav . I’ve had this same problem on ruby 2.6.8. Unfortunately I am stuck here until jruby 9.4.0.0 is released. There doesn’t seem to be anything wrong with the Rails::Application.send(:attr_accessor, :importmap) call, other than it doesn’t seem to get executed when run under ruby < 2.7.

My workaround (that seems to be working so far) is to simply add attr_accessor :importmap in the application class definition in config/application.rb.

This issue is fixed on JRuby master (9.4) and will not be an issue at release.

JRuby 9.4 will be out soon with support for Ruby 3.1 and Rails 7.

Rails 7 is going to require Ruby 2.7 as the minimum.