Wednesday 26 January 2011

Installing Sass on Ubuntu 10.04 Lucid

Sass is a CSS extension that enables you to use variables, nested rules etc. To install it, see their website. If like me, you just try the first command they give you before installing ruby, you will get this:
The program 'sass' is currently not installed. You can install it by typing:
sudo apt-get install libhaml-ruby1.8
Don't do as it says and install libhaml-ruby1.8, as you end up with an old version of Haml/Sass: 2.2.17. Instead, you first need to install Ruby and RubyGems, which is simple:
sudo apt-get install rubygems
Next, we install Sass using RubyGems (thanks for tip from Boyd Hemphill):
sudo gem install sass
You should now have Sass installed, but if you try to use it, you may still get the original "not installed" message. This is because annoyingly the RubyGems binaries directory is not automatically added to your PATH. To do this, I simply added the following to the end of my ~/.bashrc file:
export PATH=$PATH:/var/lib/gems/1.8/bin
Then restart your terminal and that should be it. You can check that it installed successfully, and that you have the latest version with the following command:
sass -v
I get the following output: Sass 3.1.15 (Brainy Betty). You can then follow the rest of the tutorial on their website to start compiling .sass files into .css files.

Additionally, see this blog post for a great walk-through in refactoring existing CSS to Sass.

4 comments:

  1. The export path part saved my life, many thanks!

    ReplyDelete
  2. You don't need "haml" for "sass" any longer:

    prompt > gem install sass -v 3.1.12

    ReplyDelete
  3. Many thanks! I didn't have /var/lib/gems/1.8/bin in my path, and the sass / compass websites just said it would work.  What they meant was "it just works" on a mac.  Yes, well, someone should tell them that  "/usr/bin/sass" is a lot different than "/var/lib/gems/1.8/bin".

    You saved me! Thanks!

    ReplyDelete
  4. Thanks for the post. I think the latest version is Sass 3.4.7 (Selective Steve) so you might want to update this post (I know it is old, but it still seems to be the best way to install sass).

    ReplyDelete