【问题标题】:File to import not found or unreadable: bootstrap-sprockets找不到或无法读取要导入的文件:bootstrap-sprockets
【发布时间】:2015-03-07 19:59:33
【问题描述】:

我正在尝试将引导程序安装到我的应用程序中,但遇到了各种问题。我已经粘贴了我的 gemfile、application.js 和错误代码。我不确定我在这里做错了什么,任何帮助将不胜感激。

styles.css.scss

// "bootstrap-sprockets" must be imported before "bootstrap" and "bootstrap/variables"
@import "bootstrap-sprockets";
@import "bootstrap";

宝石文件

source 'http://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.8'
# Use sqlite3 as the database for Active Record
group :development do
  gem 'sqlite3'
  gem 'capistrano'
end

group :production do
  gem 'pg'
  gem 'mysql2'
  gem 'activerecord-mysql-adapter'
end

# Use SCSS for stylesheets
group :assets do
  gem 'coffee-rails'
  gem 'bootstrap-sass', '~> 3.3.3'
  gem 'sass-rails', '>= 3.2'

end
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views



# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer',  platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0',          group: :doc

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

# Use debugger
# gem 'debugger', group: [:development, :test]

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin]

应用程序.js

// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require_tree .
//= require bootstrap-sprockets

这是我的错误

WARN: tilt autoloading 'sass' in a non thread-safe way; explicit require 'sass' suggested.
Completed 500 Internal Server Error in 722ms

ActionView::Template::Error (File to import not found or unreadable: bootstrap-sprockets.
Load paths:
  C:/Sites/jeepjig/app/assets/images
  C:/Sites/jeepjig/app/assets/javascripts
  C:/Sites/jeepjig/app/assets/stylesheets
  C:/Sites/jeepjig/vendor/assets/javascripts
  C:/Sites/jeepjig/vendor/assets/stylesheets
  C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/turbolinks-2.5.2/lib/assets/javascripts
  C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/jquery-rails-3.1.2/vendor/assets/javascripts
  (in C:/Sites/jeepjig/app/assets/stylesheets/styles.css.scss:2)):
    3: <head>
    4:  <%= tag :meta, name: "viewport", content: "width=device-width, initial-scale=1.0" %>
    5:   <title>JeepJig</title>
    6:   <%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track' => true %>
    7:   <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
    8:   <%= csrf_meta_tags %>
    9:
  app/assets/stylesheets/styles.css.scss:2
  app/views/layouts/application.html.erb:6:in `_app_views_layouts_application_html_erb__1034748832_48995988'


  Rendered C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/actionpack-4.1.8/lib/action_dispatch/middleware/templ
ates/rescues/_trace.html.erb (3.0ms)
  Rendered C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/actionpack-4.1.8/lib/action_dispatch/middleware/templ
ates/rescues/_request_and_response.html.erb (2.0ms)
  Rendered C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/actionpack-4.1.8/lib/action_dispatch/middleware/templ
ates/rescues/template_error.html.erb within rescues/layout (53.0ms)

【问题讨论】:

    标签: ruby-on-rails twitter-bootstrap ruby-on-rails-4


    【解决方案1】:

    更新:

    我删除了

    group :assets do

    现在我不再收到错误消息了。 我猜这在 R4 中已经贬值了

    【讨论】:

      【解决方案2】:

      我找到了这个链接,很快意识到我遇到了问题,因为我已经安装了 boostrap-sass,并且在没有重新启动 rails 服务器的情况下完成了捆绑安装。

      我希望以此作为提醒,以提醒任何其他人在这里找到自己的方式并且看不出它为什么不起作用。

      【讨论】:

        【解决方案3】:

        在 Gemfile 中删除组 :assets 而像这样指定

        gem 'bootstrap-sass', :git => 'https://github.com/twbs/bootstrap-sass.git', :branch => 'next'
        # Use SCSS for stylesheets 
        gem 'sass-rails', '~> 5.0' 
        gem 'autoprefixer-rails'
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2017-06-01
          • 1970-01-01
          • 2018-12-22
          • 1970-01-01
          • 1970-01-01
          • 2019-08-08
          • 1970-01-01
          相关资源
          最近更新 更多