# How to install Sass and Compass pre releases on an RVM

Sass and Compass alpha releases have the ability to generate sourcemaps, thus
making them very appealing.

> Maybe you also want to see my followup post:
> [How to enable sourcemaps in Sass and Compass](/how-to-enable-sourcemaps-in-sass-and-compass).

We'll be using:

- OSX 10.9 (that’s 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)

(The `$` means that it's a command written in terminal)

## Install RVM

This post assumes that you work with [RVM](https://rvm.io/) (Ruby Version
Manager), [here's how to do that](https://rvm.io/rvm/install).

You can also use the Ruby that is built into OS X, but it's safer to use the RVM
and leave the System Ruby alone.

**Btw:** If you want to use a custom Sass or Compass compiler in
[CodeKit](http://incident57.com/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 will give you the version you're running:

```shell
$ rvm use
# It might return something like
Using /Users/bob/.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.

## Upgrade Ruby

Run these from Terminal one at a time:

```shell
$ rvm get stable
$ rvm reload
$ rvm list known
```

The `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]
...
```

Now run:

```shell
$ 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
`/Users/username/.rvm/gems/ruby-1.9.3-p484`.

To switch to it:

```shell
$ rvm use ruby-1.9.3-p484
```

To check what Ruby you're using:

```shell
$ rvm use
```

### Troubleshooting

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.

Possible causes:

- 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:

```shell
$ xcode-select --install
```

More on this
[here](https://stackoverflow.com/questions/19594719/install-any-version-of-ruby-with-rvm-on-mavericks)
and
[here](https://stackoverflow.com/questions/10357804/configure-error-c-compiler-cannot-create-executables).

## 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](http://rubygems.org/gems/compass/).

```shell
# 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](http://rubygems.org/gems/compass/).

```shell
# This get the latest pre release
# At the time of writing it would be 1.0.0.alpha.18
$ gem install compass --pre
```

### Trouble shooting

If you get errors, you might have an old Ruby version, see the
[Upgrade Ruby](#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](http://rvm.io/gemsets/basics).

### Make a new gemset:

```shell
$ rvm 1.9.3-head
$ rvm gemset create mygemset
Gemset 'mygemset' created.
```

[Official RVM documentation](https://rvm.io/gemsets/creating).

### Using a gemset

```shell
$ 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 `.rvmrc` file:

```shell
rvm use ruby-1.9.3-p484
```

See my followup post on how to
[enable sourcemaps in Sass and Compass](/how-to-enable-sourcemaps-in-sass-and-compass).
