How to install Sass and Compass prereleases on an RVM
Sass and Compass alpha releases have the ability to generate sourcemaps, thus making them very appealing.
We’ll be using:
- OSX 10.9 (thats Mavericks)
- Ruby 1.9.3 (at least, can be higher)
- Sass 3.3.0.rc.3 (or the stable 3.3 when it’s out)
- and Compass 1.0.0.alpha.18 (or the stable 1.0 when it’s out)
$ means that it’s a command written in terminal)
You can also use the the Ruby that is backed into your OS X, but it’s more safe to use the RVM and leave the System Ruby alone.
Btw: If you want to use a custom Sass or Compass compiler in CodeKit, you need to use the system Ruby to do that, RVM Ruby is no good for CodeKit (at least in the >2 versions).
Check Ruby version
This’ll give you the version you’re running:
$ rvm use # It might return something like Using /Users/hilja/.rvm/gems/ruby-1.9.2-p484
If you have 1.9.3 or higher you’re good for running Sass 3.3.0.rc.3 and Compass 1.0.0.alpha.18, and can skip the Upgrade Ruby section here. If you have 1.9.2 or lower, see upgrade instructions below.
Run these from Terminal one at a time:
$ rvm get stable $ rvm reload $ rvm list known
rvm list known command will spew out a bunch of text, you’re interested in the
# MRI Rubies:
# MRI Rubies ... [ruby-]1.9.3[-p484] ...
$ rvm install 1.9.3 # Or whatever the version it is you wanna install
The installation proses starts, it’ll take some time.
You’ll find the newly installed Ruby at
To switch to it:
$ rvm use ruby-1.9.3-p484
To check what Ruby you’re using:
$ rvm use
If you’re getting errors like this:
configure: error: C compiler cannot create executables See `config.log' for more details There has been an error while running configure. Halting the installation.
You might face this especially if you’re using Mavericks.
- You don’t have Xcode installed (go to the App Store and install it)
- or you have an old version of it (go to App Store and upgrade it)
- or you don’t have the Xcode command line tools installed (go to the Xcode > Settings > Downloads and download the latest Command Line Tools)
If that won’t help, go to Terminal and run:
$ xcode-select --install
Install Sass and Compass
Now that you got the proper Ruby version up and running you can install Sass and Compass, see the Sass gem page for the latest verion.
# This gets the latest pre release # At the time of writing it's 3.3.0.rc.3 $ gem install sass --pre
When the stable 3.3 is out, you want to use it rather than the alpha. Just skip the
--pre from it:
gem install sass.
Get Compass alpha, see the Compass gem page for the latest version.
# This get the latest pre release # At the time of writing it would be 1.0.0.alpha.18 $ gem install compass --pre
If you get errors, you might have an old Ruby version, see the Upgrade Ruby above.
Using different gemsets for different projects
What if you need the old Compass on some project? Cause the project uses Compass plugin that is not compatible with the new Compass version (or something). Fret not, you can use different gemsets for different projects. See RVM docs on it.
Make a new gemset:
$ rvm 1.9.3-head $ rvm gemset create mygemset Gemset 'mygemset' created.
Using a gemset
$ rvm ruby-1.9.2-p320@mygemset
To automatically define the right gemset per project basis, you just put a file called
.rvmrc into the root of the project that has that command in it. An example
rvm use ruby-1.9.3-p484
See my followup post on how to enable sourcemaps in Sass and Compass.