I’m creating a new Rails 7 (7.0.4) app with Bootstrap like this:
rails new mynewapp -c bootstrap
And I get this:
Error: Can't find stylesheet to import.
1 │ @import 'bootstrap/scss/bootstrap';
app/assets/stylesheets/application.bootstrap.scss 1:9 root stylesheet
Is there something obvious I’m missing here? Is this intended to work “out of the box”?
Are you running with
rails s? Try switching to
./bin/dev. If I’m not mistaking that option will install bootstrap in a way that requires a yarn process that watches and updates the files.
I’ve tried both options for running it with the same result.
Thing is that I get that message upon
creation of the new app (as well as at runtime).
November 24, 2022, 4:40pm
Check Ruby versions, Rails versions, node versions. Look at your Gemfile.
This is off the top of my head. But I just ran this (although I may have some .railsrc) and need to check further. But localhost puts up a page
Are you starting your dev server with
rails s or
November 26, 2022, 2:23pm
This should work out-of-the-box. I ran exactly the same command and could start my rails app locally.
I’m running Ruby 3.1.2.
And you might check your YARN configuration as that’s the one responsible for fetching Bootstrap.
Yeah, I’ve tried:
I have also run using both:
And get the same issue. NOTE: This error does not display on the default root page, but in any custom pages I create.
Here are the versions I am running:
I should note that I am able to
run the app (though this error message also shows in the browser).
I have a new MacBook coming this week. Perhaps I will have a pristine environment to try.
December 1, 2022, 1:36pm
Can you share your
.yarnrc.yml file? I had the same issue when using the Yarn Plug’n’Play feature (
https://yarnpkg.com/features/pnp). I fixed the problem by going back to
nodeLinker: node-modules to your
(Nguyễn Thanh Tùng)
December 11, 2022, 12:42am
Have you tried yet
rails new quote-editor --css=sass