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://dostavka-izkitaya5.ru/ https://dostavka-izkitaya5.ru/: В 2026 году без нормальной растаможки на маркетпле... 04/18 21:47
https://www.oyeanuncios.com/profile/margueritecava https://www.oyeanuncios.com/profile/margueritecava: Hat jemand Tipps gegen die leichte Übelkeit in der... 04/17 23:02
https://athworldproperties.com/author/deangelonewhou/ https://athworldproperties.com/author/deangelonewhou/: Mein Stoffwechsel fühlt sich zum ersten Mal seit J... 04/17 23:00
https://hyperharmony.com/author-profile/shannaminifie/ https://hyperharmony.com/author-profile/shannaminifie/: Endlich ist dieses ständige „Food Noise“ im Kopf k... 04/17 22:49
https://www.legnostyle.ru/catalog/mebel/spalni/sp-3.html https://www.legnostyle.ru/catalog/mebel/spalni/sp-3.html: Мебель из Германии славится на весь мир своими изы... 04/16 15:20
https://slon8.at-slon6.cc https://slon8.at-slon6.cc: Superb, what a webpage it is! This weblog presents... 04/15 21:27
https://wikzaim.ru/ https://wikzaim.ru/: Если деньги нужны срочно нет желания тратить время... 04/15 18:58
https://severlight.su:443/bitrix/redirect.php?goto=https://puertadelsolsanblas.com.ar/3-super-hot-chillies-slot-spicy-reels-and-sizzling-wins/ https://severlight.su:443/bitrix/redirect.php?goto=https://puertadelsolsanblas.com.ar/3-super-hot-chillies-slot-spicy-reels-and-sizzling-wins/: I was curious if you ever thought of changing the ... 04/15 16:00