124

I am in the process of setting up a new Mac for work. I have installed Grunt & Grunt CLI globally. Then I did a npm install inside a project folder to install all dependencies.

No problems so far, but as soon as I try to run the sass:dist task, I get this warning:

Warning: You need to have Ruby and Sass installed and in your PATH for
this task to work. More info:
https://github.com/gruntjs/grunt-contrib-sass Use --force 
to continue.

What I understand is that I need to have Ruby and Sass installed on a more global level for this task to run. As I am still pretty new to working with the terminal, I did a quick search to find out what PATH is - seems like its some system path (that can be changed) where important data is stored.

Does this mean I can simply do a sudo grunt install contrib-sass -g to resolve the issue? And what about Ruby – I always thought its already installed on OS X?

1

8 Answers 8

212

Ok I got it. I just had to install Sass using gem install sass and now everything is fine...couldn't be easier.

4
  • 22
    sudo apt-get install ruby-compass : seems to install both on Ubuntu - Ruby wasn't installed in my case
    – myol
    Oct 15, 2014 at 21:00
  • 20
    On my Mac sudo was required before gem install sass. Jul 20, 2015 at 9:51
  • 1
    This is the same for Windows
    – Matt Canty
    Sep 23, 2015 at 12:51
  • 1
    (Win7) I had to manually add the Ruby bin path into PATH - only afterwards the gem install sass worked. Oct 14, 2015 at 20:16
91

If you're on OSX El Capitan or Yosemite on Mac there seem to be an issue installing the gem.

Try

sudo gem install -n /usr/local/bin sass

Solution was from github.

2
12

You need to install Ruby and Sass as:

For Ruby use command

sudo apt-get install ruby-full

And for Sass use command

sudo gem install sass
2
  • 1
    I already had ruby installed and only the command sudo gem install sass worked for me. Oct 17, 2017 at 1:59
  • just -> gem install sass Oct 27, 2017 at 20:26
8

grunt-sass documentation is not very clear. To avoid the need of Ruby, you can try this:

npm uninstall --save grunt-contrib-sass
npm install --save node-sass grunt-sass

Try this, It's work for me.

reference

3
  • 4
    This is the best answer in 2020. It makes SASS work like a charm and keeps all of the dependencies locally installed via npm. When adapting my code from grunt-contrib-sass to grunt-sass, I needed to make some adjustments to my grunt config, but their usage example made it easy: github.com/sindresorhus/grunt-sass#usage Jan 15, 2020 at 20:42
  • Great, thanks for the tip! Had been searching how to get rid of that dependency to Ruby and you answered it. I would however use rather npm install --save-dev instead of --save because you only need sass for development (I just edited this in the answer).
    – Tobias
    May 7, 2020 at 8:18
  • But after that, I had to change my Gruntfile.js: const sass = require("node-sass"); grunt.initConfig({ sass: { options: { implementation: sass } } Source: stackoverflow.com/a/68104462/6909703 Apr 24, 2022 at 9:12
2

You need to install Ruby and Sass as:

For Ruby use command

sudo apt-get install ruby-full

And for Sass use command

sudo gem install sass
1

Use grunt --force if you are using grunt. If you want to run an application using grunt and a warning is occur like this. For ignoring this warning you can use --force.

1
  • 2
    Welcome to the Stack Overflow. You should add some more description to your answer. It is not best practice to post answers with just one sentence.
    – filipst
    Mar 9, 2017 at 7:48
1

I used Homebrew to install Ruby and then Ruby to install SASS. Probably only the best way to do it if you already use Homebrew, or want to start using it regularly...

brew install ruby
gem install sass
1

Also simply brew install saas/sass/sass on Mac High Sierra (10.13.x)

0

Your Answer

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

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