Skip to content

NoMethodError: undefined method `asset' for #<Array:0x00007f78c7582900> #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wmakley opened this issue Dec 4, 2021 · 4 comments
Closed

Comments

@wmakley
Copy link

wmakley commented Dec 4, 2021

This crash occurs when the engine loads, so on boot or running the install task.

Gemfile:

gem 'rails', '~> 6.1.4', '>= 6.1.4.1'
# ...
# the following are updated to the latest versions as of this writing:
gem 'importmap-rails'
gem 'hotwire-rails'
gem 'requestjs-rails'
./bin/rails requestjs:install --trace
** Invoke requestjs:install (first_time)
** Execute requestjs:install
** Invoke requestjs:install:asset_pipeline (first_time)
** Execute requestjs:install:asset_pipeline
rails aborted!
NoMethodError: undefined method `asset' for #<Array:0x00007f78c7582900>
/Users/william/programming/coffee-log-rails/config/environment.rb:5:in `<main>'
/Users/william/programming/coffee-log-rails/bin/rails:5:in `<top (required)>'
/Users/william/programming/coffee-log-rails/bin/spring:10:in `require'
/Users/william/programming/coffee-log-rails/bin/spring:10:in `block in <top (required)>'
/Users/william/programming/coffee-log-rails/bin/spring:7:in `tap'
/Users/william/programming/coffee-log-rails/bin/spring:7:in `<top (required)>'
Tasks: TOP => app:template => environment
(See full trace by running task with --trace)

The actual crash appears to be in lib/requestjs/engine.rb, line 12::

    initializer "requestjs.importmap" do
      if Rails.application.config.respond_to?(:importmap)
        Rails.application.config.importmap.paths.tap do |paths|
          paths.asset "@rails/request.js", path: "rails-requestjs" # line 12
        end
      end
    end
@marcelolx
Copy link
Collaborator

@wmakley If you point in your gemfile to the github repo it still happen? I believe the changes here 74ce4f4 will fix your problem they just haven't been released yet

@evaneykelen
Copy link

I can confirm that using gem 'requestjs-rails', github: 'rails/requestjs-rails', ref: 'refs/pull/3/head' indeed solves the NoMethodError.

@marcelolx
Copy link
Collaborator

Should be fixed in https://github.com/rails/requestjs-rails/releases/tag/v0.0.6

Let me know if something is still broken!

@evaneykelen
Copy link

Solved with 0.0.6! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants