部署 一直碰到 File to import not found or unreadable: bootstrap-responsive. 的问题

leslin123 · 2014年01月07日 · 最后由 leslin123 回复于 2014年01月09日 · 7109 次阅读

在部署到 Ubuntu 的过程中,遇到一个奇怪的问题,搜索了半天,网上的解决方案都不行,只能来求助了。 问题现象: 在 windows 开发的,windows 上一切正常; 在页面上一直显示:We're sorry, but something went wrong.

日志显示:

Started GET "/" for 61.135.169.86 at 2014-01-07 17:28:15 +0800
Processing by WelcomeController#index as HTML
  Rendered welcome/index.html.erb within layouts/application (0.1ms)
Completed 500 Internal Server Error in 10ms

ActionView::Template::Error (application.css isn't precompiled):
    4:   <meta name="viewport" content="width=device-width, initial-scale=1.0">
    5:   <title><%= content_for?(:title) ? yield(:title) : "Rails3 Bootstrap Devise Cancan" %></title>
    6:   <meta name="description" content="<%= content_for?(:description) ? yield(:description) : "Rails3 Bootstrap Devise Cancan" %>">
    7:   <%= stylesheet_link_tag "application", :media => "all" %>
    8:   <%= javascript_include_tag "application" %>
    9:   <%= csrf_meta_tags %>
    10:   <%= yield(:head) %>
  app/views/layouts/application.html.erb:7:in `_app_views_layouts_application_html_erb__256043867756328300_38121320'

相关的 gem file:

gem 'rails', '3.2.13'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

gem 'sqlite3'


# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'

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

  gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'
gem 'bootstrap-sass'
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

# To use Jbuilder templates for JSON
# gem 'jbuilder'

试图解决:一直碰到 File to import not found or unreadable: bootstrap-responsive. 的问题

# RAILS_ENV=development bundle exec rake assets:precompile
(in /data/wwwsite/kkus)
/usr/local/rvm/rubies/ruby-1.9.3-p484/bin/ruby /usr/local/rvm/gems/ruby-1.9.3-p484/bin/rake assets:precompile:all RAILS_ENV=development RAILS_GROUPS=assets
rake aborted!
File to import not found or unreadable: bootstrap-responsive.
Load paths:
  Sass::Rails::Importer(/data/wwwsite/tusulicai/app/assets/stylesheets/bootstrap_and_overrides.css.scss)
  /usr/local/rvm/gems/ruby-1.9.3-p484/gems/bootstrap-sass-3.0.3.0/vendor/assets/stylesheets
  (in /data/wwwsite/tusulicai/app/assets/stylesheets/bootstrap_and_overrides.css.scss)
/data/wwwsite/tusulicai/app/assets/stylesheets/bootstrap_and_overrides.css.scss:3
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/sass-3.2.13/lib/sass/tree/import_node.rb:67:in `rescue in import'
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/sass-3.2.13/lib/sass/tree/import_node.rb:45:in `import'
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/sass-3.2.13/lib/sass/tree/import_node.rb:28:in `imported_file'
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/sass-3.2.13/lib/sass/tree/import_node.rb:37:in `css_import?'
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/sass-3.2.13/lib/sass/tree/visitors/perform.rb:217:in `visit_import'
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/sass-3.2.13/lib/sass/tree/visitors/base.rb:37:in `visit'

求解决方案?谢谢

自己更新一下进展, 找到一篇最新的文章,描述这个问题: http://stackoverflow.com/questions/19948584/bootstrap-not-work-in-rails-application 大意是 bootstrap 的版本有问题;我看了一下老版本的配置文件

  • bootstrap-sass (2.1.1.0) --windows 老版本
    • bootstrap-sass (3.0.3.0) --Ubuntu 的是这样的;

Bootstrap-responsive has been removed since Bootstrap 3.0.

3.0 is mobile first design, and responsiveness is native now.

Remove that require statement, no need now.

Update

Dexter(OP) finally solved the problem by going back to 2.3. Though the case is rare, I think two lessons can be learned:

Always add version to critical gems.

Always use bundle install or bundle(default to install). Only use bundle update when it's really necessary and you are fully prepared.

Gemfile里边没有指定版本号?建议养成在 Gemfile 里边指定版本号的习惯,比如:

gem 'sass-rails', '~> 3.2.3'

如 stackoverflow 哥们说的,关键是要精确制定版本好: Always add version to critical gems. Always use bundle install or bundle(default to install). Only use bundle update when it's really necessary and you are fully prepared.

@Martin91 ,恢复一批已经升级的 gem,有快捷的方法吗?

#3 楼 @leslin123 是要降回老的版本吗?

谢谢 @Martin91 ,我已经重新 bundle 了一下,重来了。

需要 登录 后方可回复, 如果你还没有账号请 注册新账号