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

Running rails_admin:install raises "@popperjs/core" importmap error #3694

Closed
punkstar opened this issue Aug 15, 2024 · 7 comments
Closed

Running rails_admin:install raises "@popperjs/core" importmap error #3694

punkstar opened this issue Aug 15, 2024 · 7 comments

Comments

@punkstar
Copy link

Describe the bug
Unable to run rails g rails_admin:install on a fresh Rails project.

Reproduction steps

$ rails new railsadmintest
$ bundle add rails_admin --version="~>3.0"
$ bundle install
$ bundle exec rails g rails_admin:install

...truncated...

/Users/nrj/.rvm/gems/ruby-3.3.0/gems/rails_admin-3.2.0.beta/lib/generators/rails_admin/importmap_formatter.rb:17:in `format': undefined method `[]' for nil (NoMethodError)

      imports['@popperjs/core'].gsub!('lib/index.js', 'dist/esm/popper.js')
             ^^^^^^^^^^^^^^^^^^
Full output from g rails_admin:install
           ?  Where do you want to mount rails_admin? Press <enter> for [admin] >
       route  mount RailsAdmin::Engine => '/admin', as: 'rails_admin'
      create  config/initializers/rails_admin.rb
           -  Using [importmap] for asset delivery method
         run  yarn add rails_admin@3.2.0-beta from "."
      create  app/javascript/rails_admin.js
/Users/nrj/.rvm/gems/ruby-3.3.0/gems/rails_admin-3.2.0.beta/lib/generators/rails_admin/importmap_formatter.rb:17:in `format': undefined method `[]' for nil (NoMethodError)

      imports['@popperjs/core'].gsub!('lib/index.js', 'dist/esm/popper.js')
             ^^^^^^^^^^^^^^^^^^
	from /Users/nrj/.rvm/gems/ruby-3.3.0/gems/rails_admin-3.2.0.beta/lib/generators/rails_admin/install_generator.rb:100:in `configure_for_importmap'
	from /Users/nrj/.rvm/gems/ruby-3.3.0/gems/rails_admin-3.2.0.beta/lib/generators/rails_admin/install_generator.rb:33:in `install'
	from /Users/nrj/.rvm/gems/ruby-3.3.0/gems/thor-1.3.1/lib/thor/command.rb:28:in `run'
	from /Users/nrj/.rvm/gems/ruby-3.3.0/gems/thor-1.3.1/lib/thor/invocation.rb:127:in `invoke_command'
	from /Users/nrj/.rvm/gems/ruby-3.3.0/gems/thor-1.3.1/lib/thor/invocation.rb:134:in `block in invoke_all'
	from /Users/nrj/.rvm/gems/ruby-3.3.0/gems/thor-1.3.1/lib/thor/invocation.rb:134:in `each'
	from /Users/nrj/.rvm/gems/ruby-3.3.0/gems/thor-1.3.1/lib/thor/invocation.rb:134:in `map'
	from /Users/nrj/.rvm/gems/ruby-3.3.0/gems/thor-1.3.1/lib/thor/invocation.rb:134:in `invoke_all'
	from /Users/nrj/.rvm/gems/ruby-3.3.0/gems/thor-1.3.1/lib/thor/group.rb:232:in `dispatch'
	from /Users/nrj/.rvm/gems/ruby-3.3.0/gems/thor-1.3.1/lib/thor/base.rb:584:in `start'
	from /Users/nrj/.rvm/gems/ruby-3.3.0/gems/railties-7.2.0/lib/rails/generators.rb:261:in `invoke'
	from /Users/nrj/.rvm/gems/ruby-3.3.0/gems/railties-7.2.0/lib/rails/commands/generate/generate_command.rb:26:in `perform'
	from /Users/nrj/.rvm/gems/ruby-3.3.0/gems/thor-1.3.1/lib/thor/command.rb:28:in `run'
	from /Users/nrj/.rvm/gems/ruby-3.3.0/gems/thor-1.3.1/lib/thor/invocation.rb:127:in `invoke_command'
	from /Users/nrj/.rvm/gems/ruby-3.3.0/gems/railties-7.2.0/lib/rails/command/base.rb:178:in `invoke_command'
	from /Users/nrj/.rvm/gems/ruby-3.3.0/gems/thor-1.3.1/lib/thor.rb:527:in `dispatch'
	from /Users/nrj/.rvm/gems/ruby-3.3.0/gems/railties-7.2.0/lib/rails/command/base.rb:73:in `perform'
	from /Users/nrj/.rvm/gems/ruby-3.3.0/gems/railties-7.2.0/lib/rails/command.rb:71:in `block in invoke'
	from /Users/nrj/.rvm/gems/ruby-3.3.0/gems/railties-7.2.0/lib/rails/command.rb:149:in `with_argv'
	from /Users/nrj/.rvm/gems/ruby-3.3.0/gems/railties-7.2.0/lib/rails/command.rb:69:in `invoke'
	from /Users/nrj/.rvm/gems/ruby-3.3.0/gems/railties-7.2.0/lib/rails/commands.rb:18:in `<main>'
	from /Users/nrj/.rvm/rubies/ruby-3.3.0/lib/ruby/3.3.0/bundled_gems.rb:74:in `require'
	from /Users/nrj/.rvm/rubies/ruby-3.3.0/lib/ruby/3.3.0/bundled_gems.rb:74:in `block (2 levels) in replace_require'
	from /Users/nrj/.rvm/gems/ruby-3.3.0/gems/bootsnap-1.18.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
	from bin/rails:4:in `<main>'

Expected behavior
Expect rails r rails_admin:install to succeed.

Additional context

  • rails version: 7.2.0
  • rails_admin version: 3.2.beta
  • rails_admin npm package version: Not sure how to check this.
  • full stack trace (if there's an exception)
/Users/nrj/.rvm/gems/ruby-3.3.0/gems/rails_admin-3.2.0.beta/lib/generators/rails_admin/importmap_formatter.rb:17:in `format': undefined method `[]' for nil (NoMethodError)

      imports['@popperjs/core'].gsub!('lib/index.js', 'dist/esm/popper.js')
             ^^^^^^^^^^^^^^^^^^
	from /Users/nrj/.rvm/gems/ruby-3.3.0/gems/rails_admin-3.2.0.beta/lib/generators/rails_admin/install_generator.rb:100:in `configure_for_importmap'
	from /Users/nrj/.rvm/gems/ruby-3.3.0/gems/rails_admin-3.2.0.beta/lib/generators/rails_admin/install_generator.rb:33:in `install'
	from /Users/nrj/.rvm/gems/ruby-3.3.0/gems/thor-1.3.1/lib/thor/command.rb:28:in `run'
	from /Users/nrj/.rvm/gems/ruby-3.3.0/gems/thor-1.3.1/lib/thor/invocation.rb:127:in `invoke_command'
	from /Users/nrj/.rvm/gems/ruby-3.3.0/gems/thor-1.3.1/lib/thor/invocation.rb:134:in `block in invoke_all'
	from /Users/nrj/.rvm/gems/ruby-3.3.0/gems/thor-1.3.1/lib/thor/invocation.rb:134:in `each'
	from /Users/nrj/.rvm/gems/ruby-3.3.0/gems/thor-1.3.1/lib/thor/invocation.rb:134:in `map'
	from /Users/nrj/.rvm/gems/ruby-3.3.0/gems/thor-1.3.1/lib/thor/invocation.rb:134:in `invoke_all'
	from /Users/nrj/.rvm/gems/ruby-3.3.0/gems/thor-1.3.1/lib/thor/group.rb:232:in `dispatch'
	from /Users/nrj/.rvm/gems/ruby-3.3.0/gems/thor-1.3.1/lib/thor/base.rb:584:in `start'
	from /Users/nrj/.rvm/gems/ruby-3.3.0/gems/railties-7.2.0/lib/rails/generators.rb:261:in `invoke'
	from /Users/nrj/.rvm/gems/ruby-3.3.0/gems/railties-7.2.0/lib/rails/commands/generate/generate_command.rb:26:in `perform'
	from /Users/nrj/.rvm/gems/ruby-3.3.0/gems/thor-1.3.1/lib/thor/command.rb:28:in `run'
	from /Users/nrj/.rvm/gems/ruby-3.3.0/gems/thor-1.3.1/lib/thor/invocation.rb:127:in `invoke_command'
	from /Users/nrj/.rvm/gems/ruby-3.3.0/gems/railties-7.2.0/lib/rails/command/base.rb:178:in `invoke_command'
	from /Users/nrj/.rvm/gems/ruby-3.3.0/gems/thor-1.3.1/lib/thor.rb:527:in `dispatch'
	from /Users/nrj/.rvm/gems/ruby-3.3.0/gems/railties-7.2.0/lib/rails/command/base.rb:73:in `perform'
	from /Users/nrj/.rvm/gems/ruby-3.3.0/gems/railties-7.2.0/lib/rails/command.rb:71:in `block in invoke'
	from /Users/nrj/.rvm/gems/ruby-3.3.0/gems/railties-7.2.0/lib/rails/command.rb:149:in `with_argv'
	from /Users/nrj/.rvm/gems/ruby-3.3.0/gems/railties-7.2.0/lib/rails/command.rb:69:in `invoke'
	from /Users/nrj/.rvm/gems/ruby-3.3.0/gems/railties-7.2.0/lib/rails/commands.rb:18:in `<main>'
	from /Users/nrj/.rvm/rubies/ruby-3.3.0/lib/ruby/3.3.0/bundled_gems.rb:74:in `require'
	from /Users/nrj/.rvm/rubies/ruby-3.3.0/lib/ruby/3.3.0/bundled_gems.rb:74:in `block (2 levels) in replace_require'
	from /Users/nrj/.rvm/gems/ruby-3.3.0/gems/bootsnap-1.18.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
	from bin/rails:4:in `<main>'
@HolyWalley
Copy link

HolyWalley commented Aug 16, 2024

same happens on Rails 7.1.3.4 and rails admin 3.1.4, ruby 3.3.0

original issue #3609

P.S. I've tried with 3.1.2 but got the same error

@bkwaku
Copy link

bkwaku commented Aug 16, 2024

Check this out - #3683

@punkstar
Copy link
Author

punkstar commented Aug 18, 2024

I'm not familiar with jspm / importmaps, etc, so take this with a pinch of salt. This issue looks like this is related to the fact that we reference a package in the codebase that's no longer present in jQuery UI.

When running the import map generator for rails_admin@3.2.0-beta (in fact, going back to >3.0) I get the error:

Error: No './ui/ie.js' exports subpath defined in https://ga.jspm.io/npm:jquery-ui@1.14.0/ resolving jquery-ui/ui/ie.js imported from https://ga.jspm.io/npm:rails_admin@3.1.0-beta/src/rails_admin/base.js.

We can see the file referenced:

import "jquery-ui/ui/ie.js";

However, this file was removed from jquery-ui in 1.14.0.

The package.json used to build 3.2.0-beta constrains jquery-ui to ^1.12.1.

As I'm writing this, I noticed a constraint change committed as part of 5245d5b which looks promising from @mshibuya 🥳

@punkstar
Copy link
Author

Related to #3695, #3692.

@jacob-carlborg-apoex
Copy link
Contributor

jacob-carlborg-apoex commented Aug 23, 2024

I'm running into this issue as well. It tried using the master branch, did not help. Does the NPM package need to be updated as well?

@punkstar
Copy link
Author

I'm running into this issue as well. It tried using the master branch, did not help. Does the NPM package need to be updated as well?

I believe so, RailsAdmin::Version.js will return 3.2.0-beta.

def js
JSON.parse(File.read("#{__dir__}/../../package.json"))['version']
end

"version": "3.2.0-beta",

@mshibuya
Copy link
Member

This was fixed as 3.2.0.rc was released. Please use it.

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

5 participants