Sass import error in Rails 3 app - “File to import not found or unreadable: compass”

I have a Rails 3 app on which I successfully ran compass init rails ./ --using blueprint. I can @import files from the /stylesheets directory, but I get an error when I try to @import compass.

Right now the app has two simple sass files:

common.scss

$body-background: blue;

main.scss

@import "common";
//@import "compass";

body { 
  background: $body-background; 
}

With the @import "compass" line commented out, this works -- I get a blue background, so I know Sass is working.

If I uncomment the line, and try to import compass or blueprint or anything else, I get an error like this.

Syntax error: File to import not found or unreadable: compass.
              Load paths:

                /Users/eric/path/to/myrailsapp/app/stylesheets
        on line 2 of /Users/eric/path/to/myrailsapp/app/stylesheets/main.scss

1: @import "common";
2: @import "compass";
3: 
4: body { 
5:  background: $body-background; 
6: }

I had through maybe I had to explicitly tell Sass where to find the Compass gem, so I added an add_import_path line to config/compass.rb:

require 'compass'
require 'html5-boilerplate'

project_type = :rails
project_path = RAILS_ROOT if defined?(RAILS_ROOT)
add_import_path "/Library/Ruby/Gems/1.8/gems/"  # unfortunately this has no effect

http_path = "/"
css_dir = "public/stylesheets"
sass_dir = "app/stylesheets"
images_dir = "public/images"
javascripts_dir = "public/javascripts"
cache_dir = "tmp/sass-cache"

http_images_path = "/images"
http_stylesheets_path = "/stylesheets"
http_javascripts_path = "/javascripts"

I have been googling for two days, and can't determine why I'm having this problem with basic @import statements. How do I tell Sass where to find the Compass and Blueprint libraries?

Answers


I was getting this error.

I changed this line in my application.rb from:

Bundler.require(:default, Rails.env) if defined?(Bundler)

to:

Bundler.require(*Rails.groups(:assets => %w(development test))) if defined?(Bundler)

Also, make sure the files are names something.css.sass NOT something.sass

And one other thing, I had an old compass.rb file in my config directory which isn't needed in Rails 3.2. Deleting that also solved this problem for me.


Need Your Help

How to create table defined in sqlalchemy schema in the Heroku server?

python heroku sqlalchemy database-schema turbogears2

I have a very simple app that I'm building with Python, SQLAlchemy, PostgreSQL and Turbogears 2.3.

jquery accordion menu animation transition

jquery css animation slider accordion

I am looking for a tutorial on how to reproduce an effect very similar to www.outdatedbrowser.com I really like the way it animates and navigates. Does anyone have any pointers. Much appreciate...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.