Laravel5用にcompassのインストールしてたらエラー出た話

## 概要

Laravel5のElixir機能には、ruby側のsassでコンパイルする機能があります。(mix.rubySass())
sassだけで書くのが辛くなり、compassをvagrantの仮想環境に一旦入れてみようとしたらエラー出まくったので、とりあえず書いておきます。
多分、ブログにも同じ記事載せます。

## 導入環境

* CentOS 6.5

## やった流れ

必要らしきパッケージのインストール

```
$ sudo yum install -y ruby rubygems
```

sassをインストール

```
$ sudo gem install sass
```

compassをインストール→エラー

```
$ sudo gem install compass
Building native extensions.  This could take a while...
ERROR:  Error installing compass:
        ERROR: Failed to build gem native extension.

/usr/bin/ruby extconf.rb
mkmf.rb can't find header files for ruby at /usr/lib/ruby/ruby.h


Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/ffi-1.9.8 for inspection.
Results logged to /usr/lib/ruby/gems/1.8/gems/ffi-1.9.8/ext/ffi_c/gem_make.out
```

mkmf.rbのエラーはruby-develが入ってないから出てたっぽいので、入れる

```
$ sudo yum install -y ruby-devel
```

mkmf.rbのエラーは消えたが、他のやつが消えない。  
ffiとかいうやつを入れてみる。

```
$ sudo gem install ffi
Building native extensions.  This could take a while...
ERROR:  Error installing ffi:
        ERROR: Failed to build gem native extension.

/usr/bin/ruby extconf.rb
checking for ffi.h... no
checking for ffi.h in /usr/local/include,/usr/include/ffi... no
checking for rb_thread_blocking_region()... no
checking for rb_thread_call_with_gvl()... no
checking for rb_thread_call_without_gvl()... no
checking for ffi_prep_cif_var()... no
creating extconf.h
creating Makefile

make
Configuring libffi
configure: WARNING: if you wanted to set the --build type, don't use --host.
    If a cross compiler is detected then cross compile mode will be used
configure: error: in `/usr/lib/ruby/gems/1.8/gems/ffi-1.9.8/ext/ffi_c/libffi-x86_64-linux':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
make: *** ["/usr/lib/ruby/gems/1.8/gems/ffi-1.9.8/ext/ffi_c/libffi-x86_64-linux"/.libs/libffi_convenience.a] Error 1


Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/ffi-1.9.8 for inspection.
Results logged to /usr/lib/ruby/gems/1.8/gems/ffi-1.9.8/ext/ffi_c/gem_make.out
```

はい、エラー。libffi-develが入ってなかったからっぽいので入れる。

```
$ sudo yum install -y libffi-devel
```

```
$ sudo gem install ffi
Building native extensions.  This could take a while...
ERROR:  Error installing ffi:
        ERROR: Failed to build gem native extension.

/usr/bin/ruby extconf.rb
checking for ffi_call() in -lffi... no
checking for ffi_call() in -llibffi... no
checking for ffi_raw_call()... no
checking for rb_thread_blocking_region()... no
checking for rb_thread_call_with_gvl()... no
checking for rb_thread_call_without_gvl()... no
checking for ffi_prep_cif_var()... no
creating extconf.h
creating Makefile

make
Configuring libffi
configure: WARNING: if you wanted to set the --build type, don't use --host.
    If a cross compiler is detected then cross compile mode will be used
configure: error: in `/usr/lib/ruby/gems/1.8/gems/ffi-1.9.8/ext/ffi_c/libffi-x86_64-linux':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
make: *** ["/usr/lib/ruby/gems/1.8/gems/ffi-1.9.8/ext/ffi_c/libffi-x86_64-linux"/.libs/libffi_convenience.a] Error 1


Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/ffi-1.9.8 for inspection.
Results logged to /usr/lib/ruby/gems/1.8/gems/ffi-1.9.8/ext/ffi_c/gem_make.out
```

どうやらgccが入ってなかったので入れる。

```
sudo yum install -y gcc
```

```
$ sudo gem install ffi
Building native extensions.  This could take a while...
Successfully installed ffi-1.9.8
1 gem installed
Installing ri documentation for ffi-1.9.8...
Installing RDoc documentation for ffi-1.9.8...
```

行けた。

```
$ sudo gem install compass
    Compass is charityware. If you love it, please donate on our behalf at http://umdf.org/compass Thanks!
Successfully installed rb-inotify-0.9.5
Successfully installed compass-1.0.3
2 gems installed
Installing ri documentation for rb-inotify-0.9.5...
Installing ri documentation for compass-1.0.3...
Installing RDoc documentation for rb-inotify-0.9.5...
Installing RDoc documentation for compass-1.0.3...
```

```
$ compass -v
Compass 1.0.3 (Polaris)
Copyright (c) 2008-2015 Chris Eppstein
Released under the MIT License.
Compass is charityware.
Please make a tax deductable donation for a worthy cause: http://umdf.org/compass
```

多分出来た。

laravelのelixir機能でコンパイルしてみる。

```
elixir(function(mix) {
    mix.rubySass(['app.scss','base.scss']);
});
```

```
$ gulp
[06:56:48] Using gulpfile /vagrant/laravel5/gulpfile.js
[06:56:48] Starting 'default'...
[06:56:48] Starting 'sass'...
[06:56:49] Finished 'default' after 576 ms
[06:56:49] gulp-ruby-sass stderr: Errno::ENOENT: No such file or directory - resources/assets/sass/app.scss,resources/assets/sass/base.scss
  Use --trace for backtrace.
[06:56:49] Finished 'sass' after 602 ms
```

どうやら、ファイルを見つけきれてない模様。これ、gulp-ruby-sassに問題があるのか、elixirに問題があるのかよく分からない。
でも、それっぽいissueはあったので、いずれ直るんでしょう。(以下の人のライブラリが取り入れられているわけでは無いのですが、同じ内容だったので)
[Ability to mix multiple sass files? - NicolasParada/laravel-elixir-ruby-sass](https://github.com/NicolasParada/laravel-elixir-ruby-sass/issues/9)
↑多分もう対応済み

## まとめ

```
yum install -y ruby rubygems ruby-devel libffi-devel gcc
gem install sass
gem install ffi
gem install compass
```