bundlerを使うとRubyアプリケーションごとに閉じたgemの依存関係を構築できるので、gemのバージョンの違いや環境ごとの違いで悩まされることが減ります。
これは非常に便利なのですが、rakeやunicornのようにコマンドをインストールするgemの場合、

pre>>
% bundle exec unicorn
<<--

のように、bundle execを介して実行する必用があって面倒です。
しかし、rvmを使えばこれを賢く解決できます。

比較的新しめのrvmとbundlerが必用になるので、
あらかじめ最新版をインストールしておいてください。

まず、以下のように適当なアプリケーション名などでgemsetを作ります。

pre>>
% rvm gemset create foo-app
<<--

作成したgemsetは

pre>>
% rvm gemset use foo-app
<<--

のようにしてアクティベートできます。新規に作成したgemsetの中身は
こんな感じになっています。

pre>>
% gem list

*** LOCAL GEMS ***

bundler (1.0.2)
rake (0.8.7)
<<--

bundler-1.0.2はちょっと古いので、gem udpateして最新のbundlerにします。

この状態であらかじめ用意しておいたGemfileに従ってgemをインストールします。

pre>>
% bundler install --system
<<--

これで foo-app gemset にはGemfileで指定したgem群が入った状態になり、rake, unicornなどのコマンド群もrvmがいい感じに取り計らってくれます。
あとは、rvm gemset use xxx を使えば適宜必用なgem環境を切り替えることができます。

ただ、アプリケーションが複数ある場合に、頻繁にgem環境を切り替えるのは面倒です。
アプリケーションのrootディレクトリに .rvmrc というファイルを作って

pre>>
rvm use ruby-1.8.7-p302@foo-app
<<--

のように記述しておいておくと、cd した時にrvmが勝手にgemsetを切り替えてくれます。これで完璧ですね!

Bye bye gem hell!

posted by genki genki on Sat 28 May 2011 at 21:36 with 0 comments
Contents rssrss
光ファイバーを二次元振動させて走査するAR用ディスプレイ
因果の取り違え
Swift2's defer for CoffeeScript
mongodb-3.0からcreateIndexのdropDupsが無くなったらしい
mongodb-3.0以降のWiredTigerの設定を動的に変更する方法
一般楕円の高速生成アルゴリズムへの道標
farro mantecatoのレシピ
Droonga関連の記事のまとめ
RuntimeErrorの特定のメッセージに限定してrescueする方法
jQueryでscriptタグを実行せずにappendする
Tags
coffeescriptdefergroongajsmemonodenodejs
Comments rssrss
https://kraken-link2025.com https://kraken-link2025.com: С практической стороны: сайт кракен тор. Ниже идё... 05/06 06:05
https://xn--ra2-6ua.com https://xn--ra2-6ua.com: Смысл этой версии — позволить избежать типичных ош... 05/06 05:33
https://cphs.fun/wiki/User:KatherineHoke74 https://cphs.fun/wiki/User:KatherineHoke74: We Supporter You Charter out Apartments In Dubai Q... 05/06 04:48
http://www.shanxihongyuan.cn/comment/html/?31555.html http://www.shanxihongyuan.cn/comment/html/?31555.html: Aѕ yoսr ցo-to Singapore furniture store аnd expans... 05/05 20:22
https://Gamedealhq.com/ https://Gamedealhq.com/: Hello mates, nice article and good urging commente... 05/05 18:46
https://processserversofhouston.com/process-server-fort-bend-county/ https://processserversofhouston.com/process-server-fort-bend-county/: I am not sure where you're getting your info, but ... 05/05 18:14
https://blindsurprise.com/ https://blindsurprise.com/: Wow, awesome weblog format! How long have you ever... 05/05 12:54
https://Mobagamezone.com/ https://Mobagamezone.com/: Simply want to say your article is as astonishing.... 05/05 12:53