`rails server`抛出错误“无法加载此类文件” - sass / logger(LoadError)

时间:2014-02-14 03:07:56

标签: ruby-on-rails ruby ruby-on-rails-3

Rails:3.2.12 Ruby:1.9.3p392(openSuse包) 操作系统:openSuse 12.3

我刚跑rails new specsheets。这很干净,包括捆绑安装:

<snip>
         run  bundle install
Fetching gem metadata from https://rubygems.org/...........
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Using rake (10.1.1) 
Using i18n (0.6.9) 
Using multi_json (1.8.4) 
Using activesupport (3.2.12) 
Using builder (3.0.4) 
Using activemodel (3.2.12) 
Using erubis (2.7.0) 
Using journey (1.0.4) 
Using rack (1.4.5) 
Using rack-cache (1.2) 
Using rack-test (0.6.2) 
Using hike (1.2.3) 
Using tilt (1.4.1) 
Using sprockets (2.2.2) 
Using actionpack (3.2.12) 
Using mime-types (1.25.1) 
Using polyglot (0.3.3) 
Using treetop (1.4.15) 
Using mail (2.4.4) 
Using actionmailer (3.2.12) 
Using arel (3.0.3) 
Using tzinfo (0.3.38) 
Using activerecord (3.2.12) 
Using activeresource (3.2.12) 
Using bundler (1.3.5) 
Using coffee-script-source (1.7.0) 
Using execjs (2.0.2) 
Using coffee-script (2.2.0) 
Using rack-ssl (1.3.3) 
Using json (1.8.1) 
Using rdoc (3.12.2) 
Using thor (0.18.1) 
Using railties (3.2.12) 
Using coffee-rails (3.2.2) 
Using jquery-rails (3.1.0) 
Using rails (3.2.12) 
Using sass (3.2.14) 
Using sass-rails (3.2.6) 
Using sqlite3 (1.3.8) 
Using uglifier (2.4.0) 
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.

当我尝试启动WEBrick服务器时,它向我抛出以下内容:

/usr/lib/ruby/gems/1.9.1/gems/sass-rails-3.2.6/lib/sass/rails/logger.rb:1:in `require': cannot load such file -- sass/logger (LoadError)
    from /usr/lib/ruby/gems/1.9.1/gems/sass-rails-3.2.6/lib/sass/rails/logger.rb:1:in `<top (required)>'
    from /usr/lib/ruby/gems/1.9.1/gems/sass-rails-3.2.6/lib/sass/rails/railtie.rb:23:in `<class:Railtie>'
    from /usr/lib/ruby/gems/1.9.1/gems/sass-rails-3.2.6/lib/sass/rails/railtie.rb:4:in `<module:Rails>'
    from /usr/lib/ruby/gems/1.9.1/gems/sass-rails-3.2.6/lib/sass/rails/railtie.rb:3:in `<top (required)>'
    from /usr/lib/ruby/gems/1.9.1/gems/sass-rails-3.2.6/lib/sass/rails.rb:16:in `require'
    from /usr/lib/ruby/gems/1.9.1/gems/sass-rails-3.2.6/lib/sass/rails.rb:16:in `<top (required)>'
    from /usr/lib/ruby/gems/1.9.1/gems/sass-rails-3.2.6/lib/sass-rails.rb:1:in `require'
    from /usr/lib/ruby/gems/1.9.1/gems/sass-rails-3.2.6/lib/sass-rails.rb:1:in `<top (required)>'
    from /usr/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `require'
    from /usr/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `block (2 levels) in require'
    from /usr/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `each'
    from /usr/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `block in require'
    from /usr/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `each'
    from /usr/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `require'
    from /usr/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler.rb:132:in `require'
    from /home/msnyder/bin/ruby/specsheets/config/application.rb:7:in `<top (required)>'
    from /usr/lib/ruby/gems/1.9.1/gems/railties-3.2.12/lib/rails/commands.rb:53:in `require'
    from /usr/lib/ruby/gems/1.9.1/gems/railties-3.2.12/lib/rails/commands.rb:53:in `block in <top (required)>'
    from /usr/lib/ruby/gems/1.9.1/gems/railties-3.2.12/lib/rails/commands.rb:50:in `tap'
    from /usr/lib/ruby/gems/1.9.1/gems/railties-3.2.12/lib/rails/commands.rb:50:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

我是铁杆新手,所以我不知道该找什么。在过去,我会转到相关目录(/usr/lib/ruby/gems/1.9.1/gems/)并确保非root用户和组可以读取所有内容。这次没有奏效。

我还注意到我的Gemfile提到了sass-rails 3.2.3,而安装的版本是3.2.6。我修改了Gemfile以反映这一点,但仍然得到了错误。

我的Gemfile:

source 'https://rubygems.org'

gem 'rails', '3.2.12'

# 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.6'
  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'

# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

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

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

# Deploy with Capistrano
# gem 'capistrano'

# To use debugger
# gem 'debugger'

应用程序目录下的日志目录为空,因此无需从那里报告。

使用sudo运行时,服务器启动正常。但是,正如我在我自己的/ home目录中所说的那样,情况并非如此。

1 个答案:

答案 0 :(得分:-1)

sass-rails放在宝石文件中的rails之上。

sass-rails gem正在尝试设置记录器,但无法找到Sass::Rails::Logger类。 https://github.com/rails/sass-rails/blob/3-2-stable/lib/sass/rails/railtie.rb#L23

这可能是因为您在有时间设置和自动加载之前调用sass。 https://github.com/rails/sass-rails/blob/3-2-stable/lib/sass/rails.rb#L7