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://www.1337games.org/de-de/online-casino/neue/ https://www.1337games.org/de-de/online-casino/neue/: Взрослый доступен через гарантированные веб-сайты.... 05/30 16:51
https://luckycaponelogin.com/ https://luckycaponelogin.com/: Das lucky capone casino, lucky capone bietet Spiel... 05/30 16:31
https://captarnegocios.com/2026/05/29/rolling-slots-casino-games-fun-play-now/ https://captarnegocios.com/2026/05/29/rolling-slots-casino-games-fun-play-now/: Very well written post. 05/30 15:49
https://www.candlestore.fr/ https://www.candlestore.fr/: Свежие xxx-платформы предлагают инновационный ко... 05/30 15:47
https://www.facebook.com/uy88cocom https://www.facebook.com/uy88cocom: https://www.facebook.com/uy88cocom https://www.yo... 05/30 13:15
https://dev.yayprint.com/furniture-singapore-everything-you-need-to-know-from-maxi-home-furniture-singapore/ https://dev.yayprint.com/furniture-singapore-everything-you-need-to-know-from-maxi-home-furniture-singapore/: Mattress Singapore 2026 – Ꮋow to Fіnd the Mattress... 05/30 13:03
https://www.binance.com/square/post/24581375290137 https://www.binance.com/square/post/24581375290137: I pay a quick visit daily a few web sites and site... 05/30 08:12
https://morman.co.uk/holland-punten-mooi-nederlands-design-voor-uw-interieur/ https://morman.co.uk/holland-punten-mooi-nederlands-design-voor-uw-interieur/: Leuk geschreven stuk, complimenten. 05/30 05:33
Services from s21g
YOMU Web小説リーダー
小説投稿サイトの公式ページを開き、WebView表示と読み上げ向け表示を切り替えて、移動中や作業中にもWeb小説の続きを聴きやすくするiPhoneアプリです。
補助探
公開されている補助金・助成金情報を集約し、条件に合う制度を探しやすくするサービスです。
jotter.me
個人開発者のためのホスティング一体型ノートサービス
ハンドミラー
iPhone向けの手鏡アプリ
ツイプロ(twpro)
Twitterプロフィールの高速検索エンジン