Why is Compass is giving me an import error when trying to import partials

user883807 picture user883807 · Jan 17, 2013 · Viewed 9.7k times · Source

My compass project directory structure looks like this

s3z@s3z:~/Desktop/compass_project$ tree
.
├── basic.html
├── config.rb
├── css
│   ├── ie.css
│   ├── print.css
│   └── screen.css
├── index.html
├── partials
│   └── _normalize.scss
└── sass
    ├── ie.scss
    ├── print.scss
    └── screen.scss

My screen.scss file looks like this

@import "compass";
@import "partials/normalize";   

When I add @import "partials/normalize"; and save it, Compass spits the following error back at me

>>> Compass is watching for changes. Press Ctrl-C to Stop.
>>> Change detected at 22:58:53 to: screen.scss
    error sass/screen.scss (Line 2: File to import not found or unreadable: partials/normalize.
Load paths:
  /home/max/Desktop/nettut_compass_tut/sass
  /home/max/.rvm/gems/ruby-1.9.3-p194/gems/compass-0.12.2/frameworks/blueprint/stylesheets
  /home/max/.rvm/gems/ruby-1.9.3-p194/gems/compass-0.12.2/frameworks/compass/stylesheets
  Compass::SpriteImporter)
overwrite ./css/screen.css 

And just in case it matters my config.rb is

http_path = "/"
css_dir = "css"
sass_dir = "sass"
images_dir = "images"
javascripts_dir = "javascripts"

Any ideas on how to fix this?

Answer

steveax picture steveax · Jan 18, 2013

You've defined your sass_dir as sass so compass is looking for that reset file in: sass/partials/normalize If you want to import something outside of your sass_dir, you need to use a path relative to the sass file that's doing the importing:

@import "../partials/normalize";

personally, I prefer to put the partial directory in the sass directory, or just let them sort to the top loose.