2013-02-23 49 views
3

我正在使用舊版Rails應用程序。並需要安裝一些新的寶石。我們設置爲使用捆綁工具。但是我被警告過,我們不能做一個簡單的安裝包,因爲對現有gem的任何更新都會使系統進入無效狀態。Ruby:如何在不更新現有版本的情況下安裝一些新寶石

那麼,如何使用包添加一些新的寶石,而無需觸摸任何現有的寶石?

回答

4

如果你做bundle install,Bundler只關心你在Gemfile中明確指定的新寶石或新版本。它還會從您的Gemfile中刪除Gemfile.lock中的任何寶石。

如果你做bundle update,那麼你最終會遇到你在你的問題中描述的問題。它會更新現有的寶石,特別是如果沒有爲每個寶石指定特定的版本。

下面是一個更深入的解釋:http://viget.com/extend/bundler-best-practices。有一個「INSTALL VS. UPDATE」部分,你可能想要閱讀。

更新

要確保你在你的寶石的版本完全控制的時候,我建議您在Gemfile引用特定版本。您可以通過指示特定的修訂版對Git引用執行相同的操作。什麼我已經最近做

例子讓sunspot_cell在我的環境中工作,根據this post

# The ability to do full document indexing has some "special needs" right now 
gem "sunspot", git: "git://github.com/sunspot/sunspot.git", ref: "f5a6b54e8c12a500acf37cfa3b4091bc57b75db0" 
gem "sunspot_solr", git: "git://github.com/sunspot/sunspot.git", ref: "f5a6b54e8c12a500acf37cfa3b4091bc57b75db0" 
gem "sunspot_rails", git: "git://github.com/sunspot/sunspot.git", ref: "f5a6b54e8c12a500acf37cfa3b4091bc57b75db0", require: "sunspot_rails" 
gem "sunspot_cell", git: 'git://github.com/zheileman/sunspot_cell.git', ref: "0c0b7f980b8c46bd272fe0a5a31d2c259bebe36e" 
gem "sunspot_cell_jars", "0.4" 
gem "progress_bar", "0.4.0" 

正如你所看到的,我想爲sunspot寶石使用github.com/sunspot/sunspot,與具體f5a6b54e8c12a500acf37cfa3b4091bc57b75db0修訂。

對於sunspot_cell_jars,我想使用sunspot_cell_jars版本0.4

這使bundle install不會讓任何東西搞砸,而是完全控制版本。

+1

好吧我跑了「捆綁安裝 - 無部署」,因爲這是一個開發機器。它看起來像安裝了新的寶石OK。現在我遇到了一個與乘客有關的問題(我們使用Apache作爲前端),「git://github.com/Goin/dm-migrations.git(在主服務器上)未檢出,請運行'bundle install' (捆紮機:: GitError)」。 dm-migrations也是現有Gemfile中列出的寶石之一,運行「bundle show dm-migrations」表明它已安裝。所以不知何故捆綁安裝已影響其他設置?請幫忙。 – SeanLabs 2013-02-23 17:55:51

+0

您可以隨時恢復您的更改。我根據您提供的信息盡我所能回答您的問題。我沒有Passenger的經驗。聽起來像這可能是另一個更具體的問題。 – 2013-02-23 17:58:50

+0

當然我會根據乘客問題發佈一個新問題。 – SeanLabs 2013-02-23 18:02:03

相關問題