twitter-bootstrap Bootstrap-sprockets 错误:未找到或无法读取要导入的文件:bootstrap-sprockets

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/35880086/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 23:43:04  来源:igfitidea点击:

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

ruby-on-railstwitter-bootstrap

提问by Tucker

I'm attempting to implement bootstrap into my app and I keep getting a couple errors that I've never received when starting apps before. I browsed for an answer and the only answers I keep finding are to remove the assetspart of the Gemfile which I don't have and to restart the server which I've done several times with no luck. Below are the errors and my files. Please let me know if something else needs to be provided. Thank you!

我正在尝试在我的应用程序中实施引导程序,但我不断收到一些我以前在启动应用程序时从未收到过的错误。我浏览了一个答案,我一直找到的唯一答案是删除assets我没有的 Gemfile 部分并重新启动服务器,我已经做了几次但都没有成功。以下是错误和我的文件。如果需要提供其他东西,请告诉我。谢谢!

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

浏览器错误:File to import not found or unreadable: bootstrap-sprockets

Rails Server Warnings:

Rails 服务器警告:

/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:

应用程序.js:

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

Application.scss:

应用程序.scss:

...

*= require_tree .
 *= require_self
 */

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

回答by beniutek

I see you have gem 'bootstrap'and gem 'bootstrap-sass'in your gemfile. If you delete one of them, run bundleand follow the installation instructions on the respective github site then the sprockets should work. Also mine application.scssfile is usually without the require part.

我看到你在你的 gemfile 中有gem 'bootstrap'gem 'bootstrap-sass'。如果您删除其中之一,请运行bundle并按照相应 github 站点上的安装说明进行操作,然后链轮应该可以工作。我的application.scss文件通常也没有 require 部分。

回答by Ed de Almeida

1o)Install the following gems in your Gemfile:

1o)在您的 Gemfile 中安装以下 gem:

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

2o)Issue the following command:

2o)发出以下命令:

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

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

3o)编辑 pp/assets/stylesheets/application.css.sass 并添加以下几行:

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

4o)Edit your app/assets/javascripts/application.js file and be sure it has the following lines:

4o)编辑您的 app/assets/javascripts/application.js 文件并确保它包含以下几行:

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

5o)Now run

5o)现在运行

bundle install

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

你准备好了!这个食谱总是对我有用,它在这个网站上

Hope it helps!

希望能帮助到你!

回答by jerom

Problem : file to import not found or unreadable bootstrap-sprockets

问题:未找到要导入的文件或无法读取的引导链

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

@import "bootstrap-sprockets"; @import "引导程序";

...........

…………

solution :

解决方案 :

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

宝石“导轨”,“5.0.0.1”宝石“引导程序”,“3.3.6”

do bundle install

做捆绑安装

then restart your rails server

然后重启你的 Rails 服务器