Why is rails_admin deleting my css and creating a package.json?

56 views Asked by At

I have a freshly created Rails 7.1 application that uses importmap (I haven't added any javascript yet, but there's no webpack here). I installed rails_admin with this command: rails g rails_admin:install --asset=importmap and it essentially broke the application.

When I try to load the application I get this error: Sprockets::Rails::Helper::AssetNotFound in Static#home on line:

<%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>

which makes sense, since rails_admin deleted application.css. But why?

Also, why did it create a package.json (twice)? Here's the output from the install command:

$ rails g rails_admin:install --asset=importmap
           ?  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 [email protected] from "."
      create  app/javascript/rails_admin.js
      create  config/importmap.rails_admin.rb
     gemfile  cssbundling-rails
        rake  css:install:sass
       apply  /home/pupeno/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/cssbundling-rails-1.3.3/lib/install/install.rb
  Build into app/assets/builds
      create    app/assets/builds
      create    app/assets/builds/.keep
      append    app/assets/config/manifest.js
  Stop linking stylesheets automatically
        gsub    app/assets/config/manifest.js
      append    .gitignore
      append    .gitignore
  Remove app/assets/stylesheets/application.css so build output can take over
      remove    app/assets/stylesheets/application.css
  Add stylesheet link tag in application layout
   unchanged    app/views/layouts/application.html.erb
  Add default package.json
      create    package.json
  Add default Procfile.dev
      create    Procfile.dev
  Ensure foreman is installed
         run    gem install foreman from "."
Fetching foreman-0.87.2.gem
Successfully installed foreman-0.87.2
Parsing documentation for foreman-0.87.2
Installing ri documentation for foreman-0.87.2
Done installing documentation for foreman after 0 seconds
1 gem installed

A new release of RubyGems is available: 3.4.10 → 3.5.3!
Run `gem update --system 3.5.3` to update your installation.

  Add bin/dev to start foreman
      create    bin/dev
         run  bundle install
Bundle complete! 22 Gemfile dependencies, 120 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
         run  bundle lock --add-platform=x86_64-linux
Writing lockfile to /home/pupeno/hamdb/Gemfile.lock
       apply  /home/pupeno/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/cssbundling-rails-1.3.3/lib/install/sass/install.rb
  Install Sass
      create    app/assets/stylesheets/application.sass.scss
         run    yarn add sass from "."
  Add build:css script
bin/rails aborted!
Rails::Generators::Error: The template [/home/pupeno/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/cssbundling-rails-1.3.3/lib/install/sass/install.rb] could not be loaded. Error: No such file or directory - npx (Rails::Generators::Error)


Caused by:
Errno::ENOENT: No such file or directory - npx (Errno::ENOENT)

Tasks: TOP => app:template
(See full trace by running task with --trace)
      create  app/assets/stylesheets/rails_admin.scss
      append  config/initializers/assets.rb
           -  Add scripts to package.json
    conflict  package.json
Overwrite /home/pupeno/hamdb/package.json? (enter "h" for help) [Ynaqdhm] y
       force  package.json

I can see it tried to use npx, but isn't the whole point of importmap to not have to use it? to not have a package.json? What am I missing here?

Oh I was install rails_admin 3.1.2. The latest one.

Thank you.

0

There are 0 answers