Rubygems,Bundler和RVM之間的關系

[英]Relationships between Rubygems, Bundler, and RVM


Following current best practices, what is the proper role for each of these?

按照目前的最佳做法,每種方法的作用是什么?

Based on my limited understanding of Bundler and RVM, it seems that they--like Rubygems--have their own install locations for gems. Plus, for each one, there's the option of installing to system paths using sudo or to your home directory. And then there's the ability to vendor gems with Bundler (where applicable, e.g. with Rails).

基於我對Bundler和RVM的有限理解,它們 - 如Rubygems - 似乎有自己的寶石安裝位置。另外,對於每一個,都可以選擇使用sudo或主目錄安裝到系統路徑。然后有能力使用Bundler供應寶石(適用時,例如使用Rails)。

So it looks to me like there are at least seven places to install gems now:

所以在我看來,現在至少有七個地方可以安裝寶石:

  • Rubygems system path
  • Rubygems系統路徑
  • Rubygems user path
  • Rubygems用戶路徑
  • RVM system path
  • RVM系統路徑
  • RVM user path
  • RVM用戶路徑
  • Bundler system path
  • Bundler系統路徑
  • Bundler user path
  • Bundler用戶路徑
  • Vendor (per-app)
  • 供應商(每個應用程序)

So, what's the best way to manage all this? Do we use all three (Rubygems, Bundler, RVM) and tell them all to install gems to the same place? Do we use sudo all the time, some of the time, or never? And should we be using a different strategy on production and development machines?

那么,管理這一切的最佳方法是什么?我們是否使用全部三個(Rubygems,Bundler,RVM)並告訴他們所有人將寶石安裝到同一個地方?我們一直在使用sudo,有時候還是從不使用sudo?我們是否應該在生產和開發機器上使用不同的策略?

On a related note, are Bundler and RVM wrappers around Rubygems, are they alternatives to it, or are they completely orthogonal to it?

在相關的說明中,圍繞Rubygems的Bundler和RVM包裝器,它們是它們的替代品,還是它們完全正交?

2 个解决方案

#1


32  

From Bundler's website:

來自Bundler的網站:

Bundler makes it easy to make sure that your application has the dependencies it needs to start up and run without errors.

Bundler可以輕松確保您的應用程序具有啟動和運行所需的依賴項,而不會出現錯誤。

This means that it's trivial for some other developer, or you on another machine, to get ready to develop further or use it, by running bundle install and you have everything you need to get up and running.

這意味着對於其他開發人員,或者您在另一台機器上,通過運行bundle install來准備進一步開發或使用它,並且您擁有啟動和運行所需的一切,這是微不足道的。

RVM is for managing multiple versions of Ruby on the same machine, and switching between them. Gemsets is a powerful feature RVM provides that isolates gems for one application/library from the rest of your system.

RVM用於在同一台機器上管理多個版本的Ruby,並在它們之間進行切換。 Gemsets是RVM提供的一項強大功能,可將一個應用程序/庫的gem與系統的其余部分隔離開來。

When using RVM and Bundler together, RVM tells Bundler where the gems should go, and Bundler installs them into the RVM-folder.

在一起使用RVM和Bundler時,RVM會告訴Bundler Gem應該去哪里,Bundler會將它們安裝到RVM文件夾中。

Both (with regards to gems in RVMs case) use and depend on Rubygems, so they're closest to wrappers.

兩者(關於RVM中的gems)使用並依賴於Rubygems,因此它們最接近包裝器。

I, personally, use Bundler and RVM for all my projects. No gemsets, just Bundler to resolve and fix things, which it does without fail. Installing gems is done without sudo, and ends up in the place RVM defines. The default Ruby install on my system is left alone, and nothing is installed to Rubygems system/user path

我個人使用Bundler和RVM來完成我的所有項目。沒有gemsets,只有Bundler來解決和修復問題,它確實沒有失敗。安裝gems是在沒有sudo的情況下完成的,最終會在RVM定義的地方完成。我的系統上的默認Ruby安裝是獨立的,並且沒有任何內容安裝到Rubygems系統/用戶路徑

#2


3  

The way I do it now (still experimenting a bit though) is this:

我現在這樣做的方式(雖然仍在嘗試一下)是這樣的:

  1. Use RVM to set up the ruby version and a gemset to use for an app. I use an .rvmrc-file in the root of the app directory to make sure the correct ruby and gemset is used all the time.

    使用RVM設置ruby版本和用於應用程序的gemset。我在app目錄的根目錄中使用.rvmrc文件,以確保始終使用正確的ruby和gemset。

  2. Bundler is installed using gem without sudo in the given gemset.

    在給定的gemset中使用gem而不使用sudo安裝Bundler。

  3. Any gems needed by the app is added to the apps Gemfile and installed using Bundler. I'm not using sudo for this.

    應用程序所需的任何寶石都會添加到應用程序Gemfile中並使用Bundler進行安裝。我沒有使用sudo。

This way I use Bundler to keep track of the dependencies for each app, and RVM to isolate each app's gems from each other. Works really smooth, actually.

這樣我就可以使用Bundler跟蹤每個應用程序的依賴關系,並使用RVM將每個應用程序的寶石相互隔離。實際上工作非常順利。

I have not yet installed RVM on my deployment server, there I just use Bundler to make sure each apps dependecies are handled. I will probably install RVM there as well, but have to figure out how that plays ball with Passenger first.

我還沒有在部署服務器上安裝RVM,在那里我只使用Bundler來確保處理每個應用程序的依賴。我也可能會在那里安裝RVM,但是必須先弄清楚如何與乘客一起玩。

As for your last question, Bundler is a wrapper around gem, RVM just manipulates the gempath where gems are installed. It seems to be smart enough that it picks up the gems from the same place though so I don't need to recompile any that are already installed in some other gemset.

至於你的上一個問題,Bundler是一個圍繞gem的包裝器,RVM只是操縱安裝了gem的gempath。它似乎很聰明,它從同一個地方獲取寶石,所以我不需要重新編譯任何已經安裝在其他gemset中的寶石。

I've stopped using sudo for installing gems after starting to use RVM. There's really no reason over just installing them in the rvm user path. I'm unsure about the best practice if you have more developers on the same machine like a test server or something like that.

在開始使用RVM之后,我已經停止使用sudo來安裝gem。沒有理由只在rvm用戶路徑中安裝它們。如果你在同一台機器上有更多的開發人員,比如測試服務器或類似的東西,我不確定最佳實踐。


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2010/12/05/725c2e480bce099512c8cd43b5ccd70d.html



 
粤ICP备14056181号  © 2014-2021 ITdaan.com