rails / sass-rails

Ruby on Rails stylesheet engine for Sass
MIT License
860 stars 333 forks source link

RSpec: "uninitialized constant Sass::Importers" #224

Closed remino closed 10 years ago

remino commented 10 years ago

Hi,

My Rails app is working fine, but when running the tests, RSpec fails while starting up with the following error: uninitialized constant Sass::Importers (NameError). Any ideas on what may be causing this?

Here is the backtrace (excluding my app):

/usr/local/opt/rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/sprockets-2.11.0/lib/sprockets/sass_importer.rb:7:in `<module:Sprockets>': uninitialized constant Sass::Importers (NameError)
        from /usr/local/opt/rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/sprockets-2.11.0/lib/sprockets/sass_importer.rb:3:in `<top (required)>'
        from /usr/local/opt/rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/sass-rails-4.0.3/lib/sass/rails/importer.rb:1:in `require'
        from /usr/local/opt/rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/sass-rails-4.0.3/lib/sass/rails/importer.rb:1:in `<top (required)>'
        from /usr/local/opt/rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/sass-rails-4.0.3/lib/sass/rails.rb:9:in `require'
        from /usr/local/opt/rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/sass-rails-4.0.3/lib/sass/rails.rb:9:in `<top (required)>'
        from /usr/local/opt/rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/sass-rails-4.0.3/lib/sass-rails.rb:1:in `require'
        from /usr/local/opt/rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/sass-rails-4.0.3/lib/sass-rails.rb:1:in `<top (required)>'
        from /usr/local/opt/rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `require'
        from /usr/local/opt/rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `block (2 levels) in require'
        from /usr/local/opt/rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `each'
        from /usr/local/opt/rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `block in require'
        from /usr/local/opt/rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `each'
        from /usr/local/opt/rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `require'
        from /usr/local/opt/rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler.rb:132:in `require'

Gemfile :

source 'https://rubygems.org'
ruby '2.0.0'

gem 'rails', '4.1.1'
gem 'pg'
gem 'sass-rails', '~> 4.0.3'
gem 'compass-rails'
gem 'uglifier', '>= 1.3.0'
gem 'bootstrap-sass', github: 'twbs/bootstrap-sass', tag: 'v3.1.1+2'
gem 'coffee-rails', '~> 4.0.0'
gem 'devise'
gem 'font-awesome-sass-rails'
gem 'htmlcompressor'
gem 'navigasmic'
gem 'omniauth'
gem 'omniauth-facebook'
gem 'omniauth-twitter'
gem 'rack-rewrite'
gem 'rails_12factor'
gem 'rails_admin'
gem 'rails_admin_uuid_field'
gem 'recipient_interceptor'
gem 'slim-rails'
gem 'unicorn-rails'

gem 'jquery-rails'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0',          group: :doc

# gem 'spring',        group: :development

group :development do
  gem 'html2slim'
  gem 'guard-livereload', require: false
  gem 'rack-livereload'
end

group :development, :test do
  gem 'dotenv-rails'
  gem 'minitest'
  gem 'rspec-rails'
end

group :test do
  gem 'cucumber-rails', require: false
  gem 'haml'
end

Gemfile.lock :

GIT
  remote: git://github.com/twbs/bootstrap-sass.git
  revision: 039f08dc011ea5f6be4b9bd2d00789cb440cc358
  tag: v3.1.1+2
  specs:
    bootstrap-sass (3.1.1.1)
      sass (~> 3.2)

GEM
  remote: https://rubygems.org/
  specs:
    actionmailer (4.1.1)
      actionpack (= 4.1.1)
      actionview (= 4.1.1)
      mail (~> 2.5.4)
    actionpack (4.1.1)
      actionview (= 4.1.1)
      activesupport (= 4.1.1)
      rack (~> 1.5.2)
      rack-test (~> 0.6.2)
    actionview (4.1.1)
      activesupport (= 4.1.1)
      builder (~> 3.1)
      erubis (~> 2.7.0)
    activemodel (4.1.1)
      activesupport (= 4.1.1)
      builder (~> 3.1)
    activerecord (4.1.1)
      activemodel (= 4.1.1)
      activesupport (= 4.1.1)
      arel (~> 5.0.0)
    activesupport (4.1.1)
      i18n (~> 0.6, >= 0.6.9)
      json (~> 1.7, >= 1.7.7)
      minitest (~> 5.1)
      thread_safe (~> 0.1)
      tzinfo (~> 1.1)
    arel (5.0.1.20140414130214)
    bcrypt (3.1.7)
    builder (3.2.2)
    capybara (2.2.1)
      mime-types (>= 1.16)
      nokogiri (>= 1.3.3)
      rack (>= 1.0.0)
      rack-test (>= 0.5.4)
      xpath (~> 2.0)
    celluloid (0.15.2)
      timers (~> 1.1.0)
    chunky_png (1.3.1)
    coderay (1.1.0)
    coffee-rails (4.0.1)
      coffee-script (>= 2.2.0)
      railties (>= 4.0.0, < 5.0)
    coffee-script (2.2.0)
      coffee-script-source
      execjs
    coffee-script-source (1.7.0)
    compass (0.12.6)
      chunky_png (~> 1.2)
      fssm (>= 0.2.7)
      sass (~> 3.2.19)
    compass-rails (1.1.2)
      compass (>= 0.12.2)
    cucumber (1.3.15)
      builder (>= 2.1.2)
      diff-lcs (>= 1.1.3)
      gherkin (~> 2.12)
      multi_json (>= 1.7.5, < 2.0)
      multi_test (>= 0.1.1)
    cucumber-rails (1.4.0)
      capybara (>= 1.1.2)
      cucumber (>= 1.2.0)
      nokogiri (>= 1.5.0)
      rails (>= 3.0.0)
    devise (3.2.4)
      bcrypt (~> 3.0)
      orm_adapter (~> 0.1)
      railties (>= 3.2.6, < 5)
      thread_safe (~> 0.1)
      warden (~> 1.2.3)
    diff-lcs (1.2.5)
    dotenv (0.11.1)
      dotenv-deployment (~> 0.0.2)
    dotenv-deployment (0.0.2)
    dotenv-rails (0.11.1)
      dotenv (= 0.11.1)
    em-websocket (0.5.1)
      eventmachine (>= 0.12.9)
      http_parser.rb (~> 0.6.0)
    erubis (2.7.0)
    eventmachine (1.0.3)
    execjs (2.2.0)
    faraday (0.9.0)
      multipart-post (>= 1.2, < 3)
    ffi (1.9.3)
    font-awesome-rails (4.1.0.0)
      railties (>= 3.2, < 5.0)
    font-awesome-sass-rails (3.0.2.2)
      railties (>= 3.1.1)
      sass-rails (>= 3.1.1)
    formatador (0.2.4)
    fssm (0.2.10)
    gherkin (2.12.2)
      multi_json (~> 1.3)
    guard (2.2.3)
      formatador (>= 0.2.4)
      listen (~> 2.1)
      lumberjack (~> 1.0)
      pry (>= 0.9.12)
      thor (>= 0.18.1)
    guard-livereload (2.0.0)
      em-websocket (~> 0.5)
      guard (~> 2.0)
      multi_json (~> 1.8)
    haml (4.0.5)
      tilt
    hashie (2.1.1)
    hike (1.2.3)
    hpricot (0.8.6)
    html2slim (0.1.0)
      hpricot
    htmlcompressor (0.1.1)
    http_parser.rb (0.6.0)
    i18n (0.6.9)
    jbuilder (2.1.0)
      activesupport (>= 3.0.0, < 5)
      multi_json (~> 1.2)
    jquery-rails (3.1.0)
      railties (>= 3.0, < 5.0)
      thor (>= 0.14, < 2.0)
    jquery-ui-rails (4.2.1)
      railties (>= 3.2.16)
    json (1.8.1)
    jwt (1.0.0)
    kaminari (0.16.1)
      actionpack (>= 3.0.0)
      activesupport (>= 3.0.0)
    kgio (2.9.2)
    listen (2.2.0)
      celluloid (>= 0.15.2)
      rb-fsevent (>= 0.9.3)
      rb-inotify (>= 0.9)
    lumberjack (1.0.4)
    mail (2.5.4)
      mime-types (~> 1.16)
      treetop (~> 1.4.8)
    method_source (0.8.2)
    mime-types (1.25.1)
    mini_portile (0.6.0)
    minitest (5.3.4)
    multi_json (1.10.1)
    multi_test (0.1.1)
    multi_xml (0.5.5)
    multipart-post (2.0.0)
    navigasmic (1.1.0)
    nested_form (0.3.2)
    nokogiri (1.6.2.1)
      mini_portile (= 0.6.0)
    oauth (0.4.7)
    oauth2 (0.9.4)
      faraday (>= 0.8, < 0.10)
      jwt (~> 1.0)
      multi_json (~> 1.3)
      multi_xml (~> 0.5)
      rack (~> 1.2)
    omniauth (1.2.1)
      hashie (>= 1.2, < 3)
      rack (~> 1.0)
    omniauth-facebook (1.6.0)
      omniauth-oauth2 (~> 1.1)
    omniauth-oauth (1.0.1)
      oauth
      omniauth (~> 1.0)
    omniauth-oauth2 (1.1.2)
      faraday (>= 0.8, < 0.10)
      multi_json (~> 1.3)
      oauth2 (~> 0.9.3)
      omniauth (~> 1.2)
    omniauth-twitter (1.0.1)
      multi_json (~> 1.3)
      omniauth-oauth (~> 1.0)
    orm_adapter (0.5.0)
    pg (0.17.1)
    polyglot (0.3.5)
    pry (0.9.12.6)
      coderay (~> 1.0)
      method_source (~> 0.8)
      slop (~> 3.4)
    rack (1.5.2)
    rack-livereload (0.3.15)
      rack
    rack-pjax (0.7.0)
      nokogiri (~> 1.5)
      rack (~> 1.3)
    rack-rewrite (1.5.0)
    rack-test (0.6.2)
      rack (>= 1.0)
    rails (4.1.1)
      actionmailer (= 4.1.1)
      actionpack (= 4.1.1)
      actionview (= 4.1.1)
      activemodel (= 4.1.1)
      activerecord (= 4.1.1)
      activesupport (= 4.1.1)
      bundler (>= 1.3.0, < 2.0)
      railties (= 4.1.1)
      sprockets-rails (~> 2.0)
    rails_12factor (0.0.2)
      rails_serve_static_assets
      rails_stdout_logging
    rails_admin (0.6.2)
      builder (~> 3.1)
      coffee-rails (~> 4.0)
      font-awesome-rails (>= 3.0)
      haml (~> 4.0)
      jquery-rails (~> 3.0)
      jquery-ui-rails (~> 4.0)
      kaminari (~> 0.14)
      nested_form (~> 0.3)
      rack-pjax (~> 0.7)
      rails (~> 4.0)
      remotipart (~> 1.0)
      safe_yaml (~> 1.0)
      sass-rails (~> 4.0)
    rails_admin_uuid_field (0.0.1)
      rails_admin (> 0.4.0)
    rails_serve_static_assets (0.0.1)
    rails_stdout_logging (0.0.3)
    railties (4.1.1)
      actionpack (= 4.1.1)
      activesupport (= 4.1.1)
      rake (>= 0.8.7)
      thor (>= 0.18.1, < 2.0)
    raindrops (0.13.0)
    rake (10.3.2)
    rb-fsevent (0.9.4)
    rb-inotify (0.9.5)
      ffi (>= 0.5.0)
    rdoc (4.1.1)
      json (~> 1.4)
    recipient_interceptor (0.1.2)
      mail
    remotipart (1.2.1)
    rspec-core (2.14.8)
    rspec-expectations (2.14.5)
      diff-lcs (>= 1.1.3, < 2.0)
    rspec-mocks (2.14.6)
    rspec-rails (2.14.0)
      actionpack (>= 3.0)
      activesupport (>= 3.0)
      railties (>= 3.0)
      rspec-core (~> 2.14.0)
      rspec-expectations (~> 2.14.0)
      rspec-mocks (~> 2.14.0)
    safe_yaml (1.0.3)
    sass (3.2.19)
    sass-rails (4.0.3)
      railties (>= 4.0.0, < 5.0)
      sass (~> 3.2.0)
      sprockets (~> 2.8, <= 2.11.0)
      sprockets-rails (~> 2.0)
    sdoc (0.4.0)
      json (~> 1.8)
      rdoc (~> 4.0, < 5.0)
    slim (2.0.2)
      temple (~> 0.6.6)
      tilt (>= 1.3.3, < 2.1)
    slim-rails (2.1.4)
      actionpack (>= 3.0, < 4.2)
      activesupport (>= 3.0, < 4.2)
      railties (>= 3.0, < 4.2)
      slim (~> 2.0)
    slop (3.5.0)
    sprockets (2.11.0)
      hike (~> 1.2)
      multi_json (~> 1.0)
      rack (~> 1.0)
      tilt (~> 1.1, != 1.3.0)
    sprockets-rails (2.1.3)
      actionpack (>= 3.0)
      activesupport (>= 3.0)
      sprockets (~> 2.8)
    temple (0.6.7)
    thor (0.19.1)
    thread_safe (0.3.4)
    tilt (1.4.1)
    timers (1.1.0)
    treetop (1.4.15)
      polyglot
      polyglot (>= 0.3.1)
    tzinfo (1.2.1)
      thread_safe (~> 0.1)
    uglifier (2.5.0)
      execjs (>= 0.3.0)
      json (>= 1.8.0)
    unicorn (4.8.3)
      kgio (~> 2.6)
      rack
      raindrops (~> 0.7)
    unicorn-rails (2.1.1)
      rack
      unicorn
    warden (1.2.3)
      rack (>= 1.0)
    xpath (2.0.0)
      nokogiri (~> 1.3)

PLATFORMS
  ruby

DEPENDENCIES
  bootstrap-sass!
  coffee-rails (~> 4.0.0)
  compass-rails
  cucumber-rails
  devise
  dotenv-rails
  font-awesome-sass-rails
  guard-livereload
  haml
  html2slim
  htmlcompressor
  jbuilder (~> 2.0)
  jquery-rails
  minitest
  navigasmic
  omniauth
  omniauth-facebook
  omniauth-twitter
  pg
  rack-livereload
  rack-rewrite
  rails (= 4.1.1)
  rails_12factor
  rails_admin
  rails_admin_uuid_field
  recipient_interceptor
  rspec-rails
  sass-rails (~> 4.0.3)
  sdoc (~> 0.4.0)
  slim-rails
  uglifier (>= 1.3.0)
  unicorn-rails
remino commented 10 years ago

I tried manually loading the required gems for Sass to work during tests, even if I don't need it at the moment. Doing this requires me to load the bootstrap-sass gem manually in config/application.rb, except for the test environment. It worked for a while, then failed again.

rafaelfranca commented 10 years ago

No idea what can cause this. Can you please provide a sample application that reproduces the error?

amccloud commented 10 years ago

I'm guessing this is similar to sstephenson/sprockets#599

remino commented 10 years ago

Turns out it was something on my end.

I tried to replicate the issue with a new app, using the same Gemfile and Gemfile.lock files, but it worked without a problem. Then, I found a local lib/sass.rb in my defective app.

This means anything requiring sass would load this local file rather than the actual gem, because of the load path. Since that didn't load sass/importers, I got the problem I mentioned above.

I renamed the conflicting file and everything works fine now.