Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
kieranklaassen opened this issue Sep 18, 2011 · 24 comments
Open

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

kieranklaassen opened this issue Sep 18, 2011 · 24 comments

Comments

@kieranklaassen
Copy link

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
Copy link

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
Copy link

avocade commented Sep 27, 2011

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
Copy link

Just echoing this problem. Anyone find a solution yet?

@kieranklaassen
Copy link
Author

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

@avocade
Copy link

avocade commented Sep 29, 2011

kieran: bundle update? :)

@kieranklaassen
Copy link
Author

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

@marcweil
Copy link

marcweil commented Oct 1, 2011

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
Copy link
Author

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
Copy link

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!

@marcweil
Copy link

marcweil commented Oct 2, 2011

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

@marcweil
Copy link

marcweil commented Oct 2, 2011

@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
Copy link

tzar commented Oct 17, 2011

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
Copy link

mkuklis commented Oct 18, 2011

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
Copy link

jpadvo commented Nov 20, 2011

@anthonylebrun Your comment fixed it for me. Thanks!

@anthonylebrun
Copy link

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

@rboyd
Copy link

rboyd commented Nov 30, 2011

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

@globalxolutions
Copy link

@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
Copy link

@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
Copy link

@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
Copy link

jpatel commented Apr 30, 2013

@anthonylebrun - Thanks for solution. It worked.

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

@Berlimioz
Copy link

@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
Copy link

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

@BJK
Copy link

BJK commented Oct 31, 2013

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests