railsadminteam/rails_admin

Fresh install fails

Andrew-Max opened this issue · 6 comments

Describe the bug
If I create a new rails 7 app and follow the install instructions, the application will not run. It fails with this error

Reproduction steps
Create a new rails 7 app and exactly follow the install instructions

Expected behavior
Installation works using the docs

Additional context

gem 'rails_admin', '~> 3.0'
gem 'sass-rails'
gem 'bootstrap', '~> 5.3.2'
gem "rails", "~> 7.0.8"
gem "sprockets-rails"

image

SassC::SyntaxError in RailsAdmin::Main#dashboard

Showing /home/amax/.rvm/gems/ruby-3.2.2/gems/rails_admin-3.1.2/app/views/layouts/rails_admin/_head.html.erb where line #19 raised:

Error: File to import not found or unreadable: rails_admin/src/rails_admin/styles/base.
        on line 2:1 of app/assets/stylesheets/rails_admin.scss
>> @import "rails_admin/src/rails_admin/styles/base";

@Andrew-Max check out this closed solution... https://github.com/railsadminteam/rails_admin/issues/3572#issuecomment-1327976864

I was getting the same issue and after updating my package.json file to include the rails_admin content, and running yarn build:css manually, I was able to move on.

package.json looks like this

...
"scripts": {
    "build:css": "sass ./app/assets/stylesheets/application.sass.scss:./app/assets/builds/application.css ./app/assets/stylesheets/rails_admin.scss:./app/assets/builds/rails_admin.css --no-source-map --load-path=node_modules"
  }
...

I also had to get my manifest.js file updated with

//= link rails_admin.css
//= link application-admin.css

I am running into this on a fresh install but running yarn build:css does not clear up the issue.

Ok I missed some red output during rails g rails_admin:install:

You need to merge "scripts": {
  "build:css": "sass ./app/assets/stylesheets/rails_admin.scss:./app/assets/builds/rails_admin.css --no-source-map --load-path=node_modules"
} into the existing scripts in your package.json.
Taking 'build:css' as an example, if you're already have application.sass.css for the sass build, the resulting script would look like:
  sass ./app/assets/stylesheets/application.sass.scss:./app/assets/builds/application.css ./app/assets/stylesheets/rails_admin.scss:./app/assets/builds/rails_admin.css --no-source-map --load-path=node_modules

Correctly following those instructions fixed my issue.