Bootstrap-Sprockets Error: import file not found or unreadable: bootstrap-sprockets

I am trying to inject bootstrap into my application, and I keep getting a couple of errors that I have never received when starting applications before. I looked at the answer, and the only answers I find is to remove the assets Gemfile part that I don’t have, and restart the server that I did several times was unlucky. Below are the errors and my files. Please let me know if something else needs to be provided. Thanks!

Browser Error: File to import not found or unreadable: bootstrap-sprockets

Rails Server Alerts:

 /Users/tucker/.rvm/gems/ruby-2.2.1/gems/bootstrap-sass-3.3.6/lib/bootstrap-sass/version.rb:2: warning: already initialized constant Bootstrap::VERSION /Users/tucker/.rvm/gems/ruby-2.2.1/gems/bootstrap-4.0.0.alpha3/lib/bootstrap/version.rb:2: warning: previous definition of VERSION was here /Users/tucker/.rvm/gems/ruby-2.2.1/gems/bootstrap-sass-3.3.6/lib/bootstrap-sass/version.rb:3: warning: already initialized constant Bootstrap::BOOTSTRAP_SHA /Users/tucker/.rvm/gems/ruby-2.2.1/gems/bootstrap-4.0.0.alpha3/lib/bootstrap/version.rb:3: warning: previous definition of BOOTSTRAP_SHA was here 

Gemfile:

 source 'https://rubygems.org' gem 'rails', '4.2.5' group :production do gem 'pg' gem 'rails_12factor' end group :development do gem 'sqlite3' end gem 'sass-rails', '~> 5.0' gem 'uglifier', '>= 1.3.0' gem 'coffee-rails', '~> 4.1.0' gem 'jquery-rails' gem 'turbolinks' gem 'bootstrap' gem 'figaro' gem 'pry' gem 'jbuilder', '~> 2.0' gem 'sdoc', '~> 0.4.0', group: :doc gem 'bootstrap-sass' group :development, :test do gem 'byebug' gem 'web-console', '~> 2.0' gem 'spring' gem 'rspec-rails' gem 'shoulda' gem 'faker' gem 'factory_girl_rails' end 

application.js:

 //= require jquery //= require bootstrap-sprockets //= require jquery_ujs //= require turbolinks //= require_tree . 

Application.scss:

 ... *= require_tree . *= require_self */ @import "bootstrap-sprockets"; @import "bootstrap"; 
+5
source share
3 answers

I see that you have gem 'bootstrap' and gem 'bootstrap-sass' in your gemfile. If you remove one of them, run bundle and follow the installation instructions on the corresponding github site, then the asterisks should work. Also my application.scss file usually does not contain the required part.

+7
source

1º) Install the following gems in the Gemfile:

 gem 'bootstrap-sass', '~> 3.3.6' gem 'autoprefixer-rails' 

2º) Run the following command:

 mv app/assets/stylesheets/application.css app/assets/stylesheets/application.css.sass 

3º) Edit pp / assets / stylesheets / application.css.sass and add the following lines:

 @import "bootstrap-sprockets" @import "bootstrap" 

4º) Edit the file app / assets / javascripts / application.js and make sure that it has the following lines:

 //= require jquery //= require jquery_ujs //= require turbolinks //= require bootstrap-sprockets //= require_tree . 

5º) Now run

 bundle install 

And you are ready! This recipe always works for me, and it is on this site .

Hope this helps!

+1
source

Problem: import file not found or unreadable bootstrap-sprockets

@import "bootstrap-sprockets"; @import "bootstrap";

...........

decision:

gem 'rails', '5.0.0.1' gem 'bootstrap-sass', '3.3.6'

install the package

then restart the rails server

-1
source

Source: https://habr.com/ru/post/1244696/


All Articles