petebrowne / sprockets-sass

Better Sass integration with Sprockets 2.x
MIT License
90 stars 29 forks source link

Import of nested partials with relative paths fails #27

Closed kukushkin closed 10 years ago

kukushkin commented 10 years ago

I have discovered a bug, trying to integrate bootstrap-sass into my project — when imported partial imports another partial using relative path, the latter fails in some circumstances.

I have managed to isolate the problem into a failing spec:

  it 'imports nested partials with relative path from the assets load path' do
    vendor = @root.directory 'vendor'
    @env.append_path vendor.to_s

    @assets.file 'folder/main.css.scss', %(@import "dep";\nbody { color: $color; })
    vendor.file 'dep.css.scss', '@import "folder1/dep1";'
    vendor.file 'folder1/_dep1.css.scss', '@import "folder2/dep2";'
    vendor.file 'folder1/folder2/_dep2.css.scss', '$color: blue;'
    asset = @env['folder/main.css']
    expect(asset.to_s).to eql("body {\n  color: blue; }\n")
  end

The spec fails saying:

     Failure/Error: asset = @env['folder/main.css']
     Sass::SyntaxError:
       File to import not found or unreadable: folder2/dep2.
       Load paths:
         /Users/alex/Projects/sprockets-sass/sass
         /Users/alex/.rvm/gems/ruby-2.1.0@sprockets-sass/gems/compass-core-1.0.0.alpha.19/stylesheets
         Compass::SpriteImporter
         (in /private/var/folders/ny/tctq5r8974qdx4n9kwwvrv5m0000gn/T/construct_container-14608-342792592/assets/folder/main.css.scss:1)
     # /private/var/folders/ny/tctq5r8974qdx4n9kwwvrv5m0000gn/T/construct_container-14608-342792592/vendor/folder1/_dep1.css.scss:1
     # /private/var/folders/ny/tctq5r8974qdx4n9kwwvrv5m0000gn/T/construct_container-14608-342792592/vendor/dep.css.scss:1
     # /private/var/folders/ny/tctq5r8974qdx4n9kwwvrv5m0000gn/T/construct_container-14608-342792592/assets/folder/main.css.scss:1
     # ./lib/sprockets/sass/sass_template.rb:53:in `evaluate'
     # ./spec/sprockets-sass_spec.rb:169:in `block (2 levels) in <top (required)>'

Now, interestingly enough, the spec does not fail if the main file is at the root level. I.e if @assets.file 'main.css.scss' ..., the spec passes.

I have tested this using:

All produced same results.

Coridyn commented 10 years ago

Hi @petebrowne, sorry to be a pain - I've just encountered this issue in one of my sites, is there a timeline to releasing a new version with this fix in it?

petebrowne commented 10 years ago

Sorry, just pushed out Version 1.2.0!