わすれっぽいきみえ

みらいのじぶんにやさしくしてやる

sqliteのインストールをbrewfileで書くには

2016-01-24 追記

github.com

しばらく見ない間にリポジトリがだいぶ更新されてた。今度触る。

2014-07-14 追記

homebrewにおけるbrew bundleコマンドは非推奨扱いになった。
What? "Warning: brew bundle is unsupported ..." · Issue #30815 · Homebrew/homebrew · GitHub
このためsqliteも無理にbrewfileで管理しない方がいいと思われる。
dotfiles系のリポジトリを管理している人はbrewfile依存のものを自分で削除していってるようだ。


何となくsqliteってmacに初めっから入ってるやつのバージョンいくつなんだろうと思って見てみたら

$ type sqlite3
sqlite3 is /usr/bin/sqlite3
$ sqlite3 -version
3.7.13 2012-07-17 17:46:21 65035912264e3acbced5a3e16793327f0a2f17bb

で、homebrewで入れられるのはいくつなんだろうと思ってみたら

$ brew info sqlite
sqlite: stable 3.8.5 (bottled)
http://sqlite.org/

This formula is keg-only.
Mac OS X already provides this software and installing another version in
parallel can cause all kinds of trouble.

OS X provides an older sqlite3.

/usr/local/Cellar/sqlite/3.8.5 (9 files, 2.1M) *
  Poured from bottle
From: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/sqlite.rb
==> Dependencies
Recommended: readline
Optional: icu4c
==> Options
--universal
    Build a universal binary
--with-docs
    Install HTML documentation
--with-fts
    Enable the FTS module
--with-functions
    Enable more math and string functions for SQL queries
--with-icu4c
    Enable the ICU module
--without-readline
    Build without readline support
--without-rtree
    Disable the R*Tree index module

brewの方がバージョン新しいですね。
というわけでインストールしたいんだけどThis formula is keg-only.という表記がある。
keg-onlyってなに(英語)っていうところを見ると

It means the formula is installed only into the Cellar, it is not linked into /usr/local. This means most tools will not find it. We don’t do this for stupid reasons. You can link the formula in still if you need to with brew link.

Cellarの中にしかインストールせず、/usr/localシンボリックリンクを貼らないという意味です。あまり見かけないものですが、くだらない理由でリンクを貼らないなんてことをしません。必要ならbrew linkを使ってください。

ということらしい。確かに

Mac OS X already provides this software and installing another version in parallel can cause all kinds of trouble.

OS X provides an older sqlite3.

Mac OS Xは既にこのソフトウェアを提供しており、平行して他のバージョンのものをインストールすると様々な問題を引き起こします。
OS X は古いバージョンのsqlite3を提供しています。

って上にも書いてた。まぁそんな困らんやろーと思って次のようにbrewfileに追記する。

install sqlite || true
link sqlite --force

これでbrew bundleしてやるとバージョンが次のようにあがる。

$ type sqlite3
sqlite3 is /usr/local/bin/sqlite3
$ sqlite3 -version
3.8.5 2014-06-04 14:06:34 b1ed4f2a34ba66c29b130f8d13e9092758019212

参考サイト
積んメモ: keg-onlyなパッケージはシンボリックリンクが作られない