sporkd / compass-html5-boilerplate

Compass version of the Html5 Boilerplate project by Paul Irish
http://html5boilerplate.com
Other
652 stars 97 forks source link

assets:precompile - File to import not found or unreadable #23

Open kieranklaassen opened 13 years ago

kieranklaassen commented 13 years ago

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
calderon commented 13 years ago

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)
avocade commented 13 years ago

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

anthonylebrun commented 13 years ago

Just echoing this problem. Anyone find a solution yet?

kieranklaassen commented 13 years ago

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

avocade commented 13 years ago

kieran: bundle update? :)

kieranklaassen commented 13 years ago

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

marcweil commented 13 years ago

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.

kieranklaassen commented 13 years ago

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

anthonylebrun commented 13 years ago

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:

If this solved your problem, let us know!

marcweil commented 13 years ago

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

marcweil commented 13 years ago

@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!

tzar commented 13 years ago

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.

mkuklis commented 13 years ago

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'

jpadvo commented 12 years ago

@anthonylebrun Your comment fixed it for me. Thanks!

anthonylebrun commented 12 years ago

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

rboyd commented 12 years ago

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

globalxolutions commented 12 years ago

@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!

davidpelaez commented 12 years ago

@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!

matteomelani commented 11 years ago

@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"

jpatel commented 11 years ago

@anthonylebrun - Thanks for solution. It worked.

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

Berlimioz commented 11 years ago

@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"

anthonylebrun commented 11 years ago

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

BJK commented 11 years ago

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"

mathieujobin commented 10 years ago

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