hawx / guard-sass

Guard::Sass automatically rebuilds sass files when modified (like sass --watch)
MIT License
88 stars 35 forks source link

Unable to @import files on relative path #36

Closed dizzib closed 11 years ago

dizzib commented 11 years ago

I have 2 files in the /build-src/sass directory:

/build-src/sass
    foo.sass
    bar.sass

where foo.sass imports bar:

@import "bar"

Guard-sass generates a 'Syntax Error: File to import not found or unreadable' error when foo.sass changes. It only works if I add /build-src/sass as a loadpath.

Interestingly the sass watcher works as expected:

sass --watch build-src/sass:build

>>> Change detected to: /build-src/sass/foo.sass
overwrite build/foo.css

and is also happy with either of these import directives:

@import "./bar"
@import "../sass/bar"

This suggests the problem might be with guard-sass.

guard-sass v0.5.4 sass v3.2.1, v3.1.15

Cheers!

ghost commented 11 years ago

If you always import bar.sass into into foo.sass, why aren't you using the following syntax:

foo.sass _bar.sass

then _bar.sass is recognized as a partial of foo.sass and should be imported and watched correct by guard:sass

hawx commented 11 years ago

@dizzib could you post your Guardfile?

dizzib commented 11 years ago

Thanks guys!

@it-consulting-lorenz same issue if I rename bar.sass to _bar.sass. The sass watcher seems happy in either case.

@hawx here's my guardfile:

guard 'sass',
    :input => 'build-src/sass',
    :output => 'build'

btw I've edited my original contrived example to match with this guardfile, hope it makes sense.

hawx commented 11 years ago

You're using an outdated version of guard-sass, try updating to 1.0.1 and see if that works ok.

dizzib commented 11 years ago

Unfortunately after updating I'm getting this error whenever I amend foo.sass:

15:04:31 - ERROR - Guard::Sass failed to achieve its <run_on_changes>, exception was:
> [#] Errno::ENOENT: No such file or directory - build-src/sass/foo.sass
> [#] /home/andy/.gem/ruby/1.9.1/gems/guard-sass-1.0.1/lib/guard/sass/runner.rb:78:in `read'

Strange thing is it's successfully detecting the change to the file which is definitely there !

guard v1.5.4 guard-sass v1.0.1 listen v0.5.3

hawx commented 11 years ago

Strange. So your directory setup is like:

.
├── Gemfile
├── Gemfile.lock
├── Guardfile
├── build
│   ├── bar.css
│   └── foo.css
└── build-src
    └── sass
        ├── bar.sass
        └── foo.sass

Then you run bundle exec guard from inside this. guard detects the change but guard-sass can't read the file.

Are you sure the path from where the command is run to the file is /build-src/sass/foo.sass, or are you running the command from somewhere else?

dizzib commented 11 years ago

Your last reply pointed me in the right direction. Turns out I was cd'ing into my scripts directory and running Guard from there.

I'm very happy to report relative import paths are now working when I run Guard from ~/ using the -G (guardfile) option :)

Thanks for your time, really appreciated!