Skip to content
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

importmap-rails download error #3626

Open
nulty opened this issue May 17, 2023 · 0 comments
Open

importmap-rails download error #3626

nulty opened this issue May 17, 2023 · 0 comments

Comments

@nulty
Copy link

nulty commented May 17, 2023

Describe the bug
When using bin/importmap pin rails_admin --download, an error is thrown. See below for full stack trace.

Reproduction steps
Steps to reproduce the issue seen.

  • rails new rails_admin_repo -j importmaps
  • cd rails_admin_repo
  • bundle add rails_admin
  • bin/importmap pin rails_admin --download

Expected behavior
I expect the jquery-ui files to each be downloaded and saved to the vendor directory.

Additional context

  • rails version: 7.0.4.3
  • rails_admin version: 3.1.2
  • rails_admin npm package version: 3.1.2
  • full stack trace (if there's an exception)
Pinning "rails_admin" to vendor/javascript/rails_admin.js via download from https://ga.jspm.io/npm:rails_admin@3.1.2/src/rails_admin/base.js
Pinning "@hotwired/turbo" to vendor/javascript/@hotwired/turbo.js via download from https://ga.jspm.io/npm:@hotwired/turbo@7.3.0/dist/turbo.es2017-esm.js
Pinning "@hotwired/turbo-rails" to vendor/javascript/@hotwired/turbo-rails.js via download from https://ga.jspm.io/npm:@hotwired/turbo-rails@7.3.0/app/javascript/turbo/index.js
Pinning "@popperjs/core" to vendor/javascript/@popperjs/core.js via download from https://ga.jspm.io/npm:@popperjs/core@2.11.7/lib/index.js
Pinning "@rails/actioncable/src" to vendor/javascript/@rails/actioncable/src.js via download from https://ga.jspm.io/npm:@rails/actioncable@7.0.4/src/index.js
Pinning "@rails/ujs" to vendor/javascript/@rails/ujs.js via download from https://ga.jspm.io/npm:@rails/ujs@6.1.7/lib/assets/compiled/rails-ujs.js
Pinning "bootstrap" to vendor/javascript/bootstrap.js via download from https://ga.jspm.io/npm:bootstrap@5.2.3/dist/js/bootstrap.esm.js
Pinning "flatpickr" to vendor/javascript/flatpickr.js via download from https://ga.jspm.io/npm:flatpickr@4.6.13/dist/esm/index.js
Pinning "jquery" to vendor/javascript/jquery.js via download from https://ga.jspm.io/npm:jquery@3.7.0/dist/jquery.js
Pinning "jquery-ui/ui/" to vendor/javascript/jquery-ui/ui/.js via download from https://ga.jspm.io/npm:jquery-ui@1.13.2/ui/
/$HOME/.asdf/installs/ruby/3.2.1/lib/ruby/gems/3.2.0/gems/importmap-rails-1.1.5/lib/importmap/packager.rb:81:in `handle_failure_response': Unexpected response code (404) (Importmap::Packager::HTTPError)
        from /$HOME/.asdf/installs/ruby/3.2.1/lib/ruby/gems/3.2.0/gems/importmap-rails-1.1.5/lib/importmap/packager.rb:119:in `download_package_file'
        from /$HOME/.asdf/installs/ruby/3.2.1/lib/ruby/gems/3.2.0/gems/importmap-rails-1.1.5/lib/importmap/packager.rb:58:in `download'
        from /$HOME/.asdf/installs/ruby/3.2.1/lib/ruby/gems/3.2.0/gems/importmap-rails-1.1.5/lib/importmap/commands.rb:21:in `block in pin'
        from /$HOME/.asdf/installs/ruby/3.2.1/lib/ruby/gems/3.2.0/gems/importmap-rails-1.1.5/lib/importmap/commands.rb:18:in `each'
        from /$HOME/.asdf/installs/ruby/3.2.1/lib/ruby/gems/3.2.0/gems/importmap-rails-1.1.5/lib/importmap/commands.rb:18:in `pin'
        from /$HOME/.asdf/installs/ruby/3.2.1/lib/ruby/gems/3.2.0/gems/thor-1.2.2/lib/thor/command.rb:27:in `run'
        from /$HOME/.asdf/installs/ruby/3.2.1/lib/ruby/gems/3.2.0/gems/thor-1.2.2/lib/thor/invocation.rb:127:in `invoke_command'
        from /$HOME/.asdf/installs/ruby/3.2.1/lib/ruby/gems/3.2.0/gems/thor-1.2.2/lib/thor.rb:392:in `dispatch'
        from /$HOME/.asdf/installs/ruby/3.2.1/lib/ruby/gems/3.2.0/gems/thor-1.2.2/lib/thor/base.rb:485:in `start'
        from /$HOME/.asdf/installs/ruby/3.2.1/lib/ruby/gems/3.2.0/gems/importmap-rails-1.1.5/lib/importmap/commands.rb:142:in `<main>'
        from <internal:/$HOME/.asdf/installs/ruby/3.2.1/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
        from <internal:/$HOME/.asdf/installs/ruby/3.2.1/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
        from /$HOME/.asdf/installs/ruby/3.2.1/lib/ruby/gems/3.2.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
        from /$HOME/.asdf/installs/ruby/3.2.1/lib/ruby/gems/3.2.0/gems/zeitwerk-2.6.8/lib/zeitwerk/kernel.rb:38:in `require' from bin/importmap:4:in `<main>'

Add any other context about the problem here.

My understanding is that importmap-rails makes a request to jspm.io for the import maps for the library. The service returns an invalid(?) importmap for jquery-ui

[1] pry(#<Importmap::Packager>)> JSON.parse(response.body).dig("map", "imports")
=> {"rails_admin"=>"https://ga.jspm.io/npm:rails_admin@3.1.2/src/rails_admin/base.js",
 "@hotwired/turbo"=>"https://ga.jspm.io/npm:@hotwired/turbo@7.3.0/dist/turbo.es2017-esm.js",
 "@hotwired/turbo-rails"=>"https://ga.jspm.io/npm:@hotwired/turbo-rails@7.3.0/app/javascript/turbo/index.js",
 "@popperjs/core"=>"https://ga.jspm.io/npm:@popperjs/core@2.11.7/lib/index.js",
 "@rails/actioncable/src"=>"https://ga.jspm.io/npm:@rails/actioncable@7.0.4/src/index.js",
 "@rails/ujs"=>"https://ga.jspm.io/npm:@rails/ujs@6.1.7/lib/assets/compiled/rails-ujs.js",
 "bootstrap"=>"https://ga.jspm.io/npm:bootstrap@5.2.3/dist/js/bootstrap.esm.js",
 "flatpickr"=>"https://ga.jspm.io/npm:flatpickr@4.6.13/dist/esm/index.js",
 "jquery"=>"https://ga.jspm.io/npm:jquery@3.7.0/dist/jquery.js",
 "jquery-ui/ui/"=>"https://ga.jspm.io/npm:jquery-ui@1.13.2/ui/"}

"jquery-ui/ui/"=>"https://ga.jspm.io/npm:jquery-ui@1.13.2/ui/" this line cannot be resolved. I'm guessing each of the jquery-ui library components should be returned in this json?

This is where importmaps is attempting to download the "file" https://github.com/rails/importmap-rails/blob/main/lib/importmap/packager.rb#LL57C23-L57C23

Is it that rails_admin could be packaged in such a way that the import maps returned are downloadable?

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

1 participant