Rails 3 Compass import problem - "File to import not found or unreadable"

891 views
Skip to first unread message

Eric Wright

unread,
May 14, 2011, 5:45:16 PM5/14/11
to Compass
I have a Rails 3 app with compass installed, with two simple scss
files:

common.scss:
$body-background: blue;

main.scss:
@import 'common';
//@import 'compass';

body {
background: $body-background;
}


If I comment out the "@import 'compass';" line, this all works -- I
get a blue background, so I know Sass is working. But if I uncomment
that line I get the error:

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 thought maybe it doesn't know how to find compass, so I added the
following to config/compass.rb:

add_import_path "/Library/Ruby/Gems/1.8/gems/"

But that didn't make any difference. I've googled for two days with
no luck. Why can't Sass import anything from compass?

-----

For reference, here is the entire 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/"

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"



(Let me know if you need any other info to help.)

Chris Eppstein

unread,
May 14, 2011, 8:32:02 PM5/14/11
to compas...@googlegroups.com
Did you add compass to your Gemfile? This is what happens when compass isn't loaded.

chris


--
You received this message because you are subscribed to the Google Groups "Compass" group.
To post to this group, send email to compas...@googlegroups.com.
To unsubscribe from this group, send email to compass-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/compass-users?hl=en.


Eric Wright

unread,
May 16, 2011, 7:19:57 PM5/16/11
to Compass
Yes, compass is in the Gem file. The line verbatim is

gem "compass", ">= 0.11.1"

And when I run $bundle install, I get

$ bundle install
Using compass (0.11.1)
... other gems ...
Your bundle is complete! Use `bundle show [gemname]` to see where a
bundled gem is installed.
$ bundle show compass
/Library/Ruby/Gems/1.8/gems/compass-0.11.1
$

I feel like Sass doesn't know where to find the compass files. I
don't know enough about the internals of Sass or Compass to know where
this is set. In my head it's something like (in pseudocode),
Sass.add_load_path(Compass.path_to_gem)

I'd appreciate any troubleshooting tips -- ways to crack open what's
happening and figure out which part of the app is dropping the ball.

Chris Eppstein

unread,
May 17, 2011, 12:30:03 AM5/17/11
to compas...@googlegroups.com
What version of rails?

Eric Wright

unread,
May 17, 2011, 7:13:34 AM5/17/11
to Compass
$ rails --version
Rails 3.0.7
$

Chris Eppstein

unread,
May 17, 2011, 2:36:00 PM5/17/11
to compas...@googlegroups.com
I think it's best if we can chat interactively. Can you come to #compass on irc.freenode.net?

Wright Eric

unread,
May 20, 2011, 9:55:18 AM5/20/11
to compas...@googlegroups.com
When would be a good time for you? I'm away until Sunday evening or we could talk any evening during the week. 

(and thanks for the help - I really appreciate it)

Eric Wright

Eric Wright

unread,
May 22, 2011, 4:30:39 PM5/22/11
to Compass
Okay, after help from Chris we were able to find the offending line.
In config/environments.rb I had this line:

Sass::Plugin.options[:template_location] = {
"#{RAILS_ROOT}/app/stylesheets" => "#{RAILS_ROOT}/public/stylesheets"
}

With the currently versions of Rails (I have 3.0.7) and Compass
(0.11.1) this line is NOT NECESSARY. I added it after following a
tutorial. If sass can't find compass, it might be because this line is
messing up your Sass::Plugin.options[:template_location].




On May 20, 9:55 am, Wright Eric <eawri...@gmail.com> wrote:
> When would be a good time for you? I'm away until Sunday evening or we could talk any evening during the week.
>
> (and thanks for the help - I really appreciate it)
>
> Eric Wright
> ericwri...@fastmail.fm
>
> On May 17, 2011, at 2:36 PM, Chris Eppstein <ch...@eppsteins.net> wrote:
>
>
>
>
>
>
>
> > I think it's best if we can chat interactively. Can you come to #compass on irc.freenode.net?
>
> > For more options, visit this group athttp://groups.google.com/group/compass-users?hl=en.
Reply all
Reply to author
Forward
0 new messages