compass-html5-boilerplate icon indicating copy to clipboard operation
compass-html5-boilerplate copied to clipboard

assets:precompile - File to import not found or unreadable

Open kieranklaassen opened this issue 12 years ago • 24 comments

I keep getting this error while precompiling the assets in my Rails 3.1.0 app on deployment to my Heroku server.

Running: rake assets:precompile
       rake aborted!
       File to import not found or unreadable: html5-boilerplate.
       Load path: Sass::Rails::Importer(/tmp/build_1uvdudt9q799d/app/assets/stylesheets/application.css.scss)
       (in /tmp/build_1uvdudt9q799d/app/assets/stylesheets/application.css.scss)

config/compass.rb

require 'html5-boilerplate'
project_type = :rails

app/assets/stylesheets/application.css.scss

// Here's where we define some default constants
@import "partials/base";

// Then we'll import the compass + boilerplate extension
@import "blueprint";
@import "compass";
@import "html5-boilerplate";

Gemfile

group :assets do
  gem 'sass-rails', "~> 3.1.0"
  gem 'coffee-rails', "~> 3.1.0"
  gem 'uglifier'
  gem 'compass'
  gem 'html5-boilerplate'
end

kieranklaassen avatar Sep 18 '11 17:09 kieranklaassen

Same error. Is it needed to do something special? Just run 'rails server' and I got this:

File to import not found or unreadable: html5-boilerplate.
Load path: Sass::Rails::Importer([MY_PROJECT]...app/assets/stylesheets/style.scss)
  (in [MY_PROJECT].../app/assets/stylesheets/style.scss)

calderon avatar Sep 27 '11 14:09 calderon

Same error here, can't import compass or susy. Works fine in development.

Using latest sass-rails commit on 3-1-stable (which fixed some rails 3.1.1rc1 issues).

avocade avatar Sep 27 '11 18:09 avocade

Just echoing this problem. Anyone find a solution yet?

anthonylebrun avatar Sep 29 '11 19:09 anthonylebrun

i got it working know but don't know why yet :-), keep you posted

kieranklaassen avatar Sep 29 '11 20:09 kieranklaassen

kieran: bundle update? :)

avocade avatar Sep 29 '11 20:09 avocade

maybe thats it yeah :-D, and i switched from the rails 3-1 stable branch on github to the gem again

kieranklaassen avatar Sep 29 '11 20:09 kieranklaassen

I just started running into this problem too. However, it only happens when I run rake assets:precompile and not when I'm just running my local server in dev mode.

marcweil avatar Oct 01 '11 02:10 marcweil

Does this work locally: RAILS_ENV=production bundle exec rake assets:precompile?

What I do now is running the asset precomile locally, checking the generated files out in git and pushing it to heroku. This way where is no need for server side assets:precompile.

Check this out if you haven't already: http://devcenter.heroku.com/articles/rails31_heroku_cedar#the_asset_pipeline

kieranklaassen avatar Oct 01 '11 09:10 kieranklaassen

If you're having trouble when switching from development to production mode, try explicitly setting your sass load_paths:

application.rb

require 'rails/all'
require "sass-rails" # add this here

application.rb (down a few lines)

module AppName
  class Application < Rails::Application
    # add these three lines:
    config.sass.load_paths ||= []
    config.sass.load_paths << "#{Rails.root}/app/assets/stylesheets"
    config.sass.load_paths << "#{Gem.loaded_specs['compass'].full_gem_path}/frameworks/compass/stylesheets"

(change the last line accordingly - I was having issues doing @import "compass/etc")

I don't know what was causing it to break, but doing this worked for me.

Details:

  • Using rails (3.1.0)
  • Using sass-rails (3.1.3)
  • Using compass (0.11.5)

If this solved your problem, let us know!

anthonylebrun avatar Oct 01 '11 16:10 anthonylebrun

@anthonylebrun So it turns out that downgrading my version of compass by a point release fixed the problem. Thanks for the help though!

marcweil avatar Oct 02 '11 10:10 marcweil

@kieranklaassen That hadn't been working locally, no. I'm also not using Heroku. By locking compass at revision 7147147e2412, the problem was resolved. At least I was able to fix it!

marcweil avatar Oct 02 '11 10:10 marcweil

I fixed the problem by commenting out config.assets.initialize_on_precompile = false in application.rb - it was there because devise recommended it, but so far it seems to work fine without it.

tzar avatar Oct 17 '11 22:10 tzar

seems like I still run into this problem regardless of config.assets.initialize_on_precompile and gem 'compass', git: "https://github.com/chriseppstein/compass.git", ref: '7147147e2412'

mkuklis avatar Oct 18 '11 05:10 mkuklis

@anthonylebrun Your comment fixed it for me. Thanks!

jpadvo avatar Nov 20 '11 05:11 jpadvo

@jpadvo great! This one gave me a headache so I'm glad to it was useful to someone else!

anthonylebrun avatar Nov 21 '11 02:11 anthonylebrun

@anthonylebrun your fix also worked here. now we just need to make it work out of the box.

rboyd avatar Nov 30 '11 22:11 rboyd

@anthonylebrun your fix also worked for me. But I had to add an additional path for html5-boilerplate:

config.sass.load_paths << "#{Gem.loaded_specs['html5-boilerplate'].full_gem_path}/stylesheets"

Thanks!

globalxolutions avatar Jan 04 '12 05:01 globalxolutions

@anthonylebrun It worked. This was so useful. Once again I have no idea why this works. Asset pipeline is so whiny and buggy sometimes. Thanks for the help!

davidpelaez avatar Aug 15 '12 05:08 davidpelaez

@anthonylebrun +1, your hacks worked for me. Thanks!

All I need was the following line in environment.rb: config.sass.load_paths << "#{Gem.loaded_specs['compass'].full_gem_path}/frameworks/compass/stylesheets"

matteomelani avatar Nov 16 '12 22:11 matteomelani

@anthonylebrun - Thanks for solution. It worked.

Definitely would like other solution which doesn't require explicitly setting of sass load_paths

jpatel avatar Apr 30 '13 17:04 jpatel

@anthonylebrun : thanks !!! For me that was compass-h5bp. All I needed was to add this into application.rb: config.sass.load_paths ||= [] config.sass.load_paths << "#{Gem.loaded_specs['compass-h5bp'].full_gem_path}/stylesheets"

Berlimioz avatar Jun 06 '13 15:06 Berlimioz

@Berlimioz 2 years later and this fix is still helping people. If only this was a stackoverflow answer ;)

anthonylebrun avatar Jun 06 '13 15:06 anthonylebrun

For rails 4 I created a sass.rb initializer with this line of code:

Sass.load_paths << "#{Gem.loaded_specs['compass-h5bp'].full_gem_path}/stylesheets"

BJK avatar Oct 31 '13 19:10 BJK

Another year later... we are still running into this issue

mathieujobin avatar Oct 30 '14 19:10 mathieujobin