0

I've read the grunt, sass, and compass documentation but can't find much about this error. I also saw another person with a similar error but it was due to syntax problems in their contrib.rb file, which I don't believe I have in my contrib.rb file.

Problem: I run the grunt watch task and get an error anytime I make a change to my sass (*.scss) files. The error reads as follows:

NoMethodError on line 264 of /Library/Ruby/Gems/1.8/gems/compass-0.12.2/lib/compass/configuration/inheritance.rb: _
Run with --trace to see the full backtrace

As a result, none of my sass files are processing to my css folder. I'm new to grunt and am admittedly a little overwhelmed with the amount of initial setup I've done. I'd love any advice as to how my files might be configured incorrectly or whether there might be an error with one of the versions of compass or sass as it relates to grunt (all are most recent non-beta versions).

Here is the text of my contrib.rb file:

require "susy"
css_dir = _/css
sass_dir = _/components/sass
javascripts_dir = _/js 
output_style = :compressed

My gruntfile.js :

module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-compass');
grunt.initConfig({
  uglify: {
    my_target: {
        files: {
            '_/js/script.js': ['_/components/js/*.js'] //tells grunt to track and compress any .js file found in components/js folder   
        } //files
      } // my_target
    }, // uglify
  compass: {
    dev: {
        options: {
            config: 'config.rb',
        force: true // <-- ???
        } //options
    } //dev
  }, //compass
  watch: {
    options: { livereload: true },
    scripts: {
        files: ['_/components/js/*.js'],
        tasks: ['uglify']
    }, //scripts
    sass: {
        files: ['_/components/sass/*.scss'],
        tasks: ['compass:dev']
    }, //sass
    html: {
      files: ['*.html']
    }
   } // watch
  })// initConfig
 grunt.registerTask('default', 'watch'); //makes 'grunt' command automaticaly execute the watch command to monitor JS files
} //exports

And my project folder structure:

sass_first_proj
   |
   _(folder)
     |
     components
     |
     css
     |
     js
   images
   node_modules
     |
     grunt
     |
     grunt-contrib-compass
     |
     grunt-contrib-uglify
     |
     grunt-contrib-watch
     |
     matchdep

 .gitignore
 |
 config.rb
 |
 gruntfile.js
 |
 index.html
 |
 package.json
10
  • Are you able to just run grunt compass or do you get the same error? My guess is the problem is not with the watch task at all. Jan 8, 2014 at 23:17
  • I'm generating the same error when I run grunt compass, and still haven't had any luck with getting the css file to link to the scss file.
    – Jim
    Jan 13, 2014 at 15:45
  • Hmm... can you just run compass from the command line directly? I'm not sure exactly what the arguments are that you'll need. But if that doesn't run either then it may not be a problem with Grunt at all. Jan 13, 2014 at 16:15
  • I'm able to run the compass watch task from the command line with no error messages, but when I change into my project directory (the root folder shown above as sass_first_proj)I generate the NoMethodError again.
    – Jim
    Jan 13, 2014 at 19:04
  • I'm not talking about the Grunt task, I'm asking if you can run compass itself from the command line, outside of Grunt. We need to isolate the problem to either compass or the watch task. But with an error like that my guess is that it's a compass issue. Jan 13, 2014 at 19:39

2 Answers 2

1

Not sure if you were able to solve this, but I was receiving the same error.

I had to include a forward slash before the directories to get Grunt to the right paths. I'm using similar steps in using Grunt and Compass for my project, and I'm on my PC so I just put the paths in single quotes. Based on how your project directory is structured, the two respective lines in the config.rb file would look like this:

css_dir = '/_/css'
sass_dir = '/_/components/sass'

Also in your question, I noticed you stated it was the "contrib.rb" file, but in your file directory that it is named config.rb. You reference it in your gruntfile.js file as config.rb, as well, but I just wanted to make sure that this file in the root of your project was being named "config.rb".

I know it was a lot of setup, so I hope this works for you.

0

So here's the thing, I've never used a contrib.rb file when using compass with Grunt. I know you can, and if you get it working, great. but the other option is to just specify the paths in the grunt config. Of course, this all assumes that you are able to actually compile the sass files. When googling for that error, it seems that much of the time it was an issue with the contrib.rb file that caused the issue.

So with that said, maybe you could leave off the contrib.rb file and just use Grunt?

compass: {
  dev: {
    options: {
      sassDir: "_/components/sass",
      specify: "_/components/sass/**/*.scss", // might not be necessary for you
      cssDir: "_/css",
      javascriptsPath: "_/js",
      outputStyle: "compressed",
      require: "susy"
    }
  }
}
2
  • Gave that a try and played around with a few more ideas I've have after looking at the gruntfile.js on github, but still no luck. I really appreciate all the help but think my best bet is to blow it all up and start over. If I come up with any solution, I'll post them here. Thanks again!
    – Jim
    Jan 21, 2014 at 18:42
  • Argh... that's too bad. Feel free to post here if you find a solution, maybe we can get a side-by-side of the old and new to see what changed. Good luck. Jan 21, 2014 at 18:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.