简体   繁体   中英

`rails server` throws error “cannot load such file” — sass/logger (LoadError)

Rails: 3.2.12 Ruby: 1.9.3p392 (openSuse package) OS: openSuse 12.3

I just ran rails new specsheets . This ran cleanly including the bundle install:

<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.

When I attempt to start the WEBrick server it throws the following at me:

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

I'm new to rails so I don't know what to look for. In the past I'd go to the directory in question (/usr/lib/ruby/gems/1.9.1/gems/) and make sure everything was readable by non-root users and groups. This hasn't worked this time around.

I also noticed that my Gemfile mentioned sass-rails 3.2.3 while the installed version is 3.2.6. I modified the Gemfile to reflect this but still get the errors.

My 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'

The log directory under the application directory is empty so there is nothing to report from there.

The server starts fine when run with sudo . However, as I have this in my own /home directory that shouldn't be the case.

Put sass-rails above rails in your gemfile.

The sass-rails gem is trying to setup the logger and cannot find the Sass::Rails::Logger class. https://github.com/rails/sass-rails/blob/3-2-stable/lib/sass/rails/railtie.rb#L23

This is probably because you are calling sass before it has time to setup and autoload. https://github.com/rails/sass-rails/blob/3-2-stable/lib/sass/rails.rb#L7

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM