Relations between Rubygems, Bundler and RVM

Following current best practices, what is the appropriate role for each of them?

Based on my limited understanding of Bundler and RVM, it seems like Rubygems have their own gem setting sites. In addition, for each of them, it is possible to install on system paths using sudo or in your home directory. And then there is the opportunity to sell gems using the Bundler (where applicable, for example, with Rails).

So, it seems to me that now there are at least seven places for setting gems:

  • The path to the Rubygems system
  • Rubygems user path
  • RVM System Path
  • RVM user path
  • Bundler System Path
  • Bundler user path.
  • Provider (per application)

So what is the best way to handle this? Do we use all three (Rubygems, Bundler, RVM) and tell them everything to set the gems in the same place? Do we use sudo all the time, some time or never? And should we use a different strategy for production and development machines?

Regarding the note, are the Bundler and RVM wrappers around Rubygems, are they an alternative to it or are they completely orthogonal to it?

+28
ruby-on-rails rubygems passenger rvm bundler
Dec 05 '10 at 22:25
source share
2 answers

From the Bundler website :

The Bundler makes it easy to verify that your application has the dependencies needed to start and run without errors.

This means that it’s trivial for any other developer or on another machine to prepare for further development or to use it by running bundle install , and you have everything you need to start and run.

RVM is designed to manage and switch between several versions of Ruby on the same machine. Gemsets is a powerful RVM feature that extracts gems for one application / library from the rest of your system.

When using the RVM and the Bundler together, the RVM tells the Bundler where the stones should be, and the Bundler installs them in the RVM folder.

Both (with respect to gems in the case of RVM) use and depend on Rubygems, so they are closest to wrappers.

I personally use Bundler and RVM for all my projects. There is no gemset, just a bundler to solve and fix things that he does without fail. Gemstone installation is done without sudo and ends at the location that defines the RVM. The default Ruby installation on my system is left alone, and nothing is installed on the Rubygems user system / path.

+31
Dec 05 '10 at 22:39
source share

How am I doing this now (still experimenting a bit):

  • Use RVM to configure the ruby ​​version and gemset for use in the application. I use the .rvmrc file in the root of the application directory to make sure the correct ruby ​​and gemset are used all the time.

  • The bundler is installed using gem without sudo in this gemset.

  • Any stones needed by the application are added to the Gemfile application and installed using the Bundler. I do not use sudo for this.

Thus, I use the Bundler to track dependencies for each application and RVM to isolate each application from stones from each other. It actually works very smoothly.

I have not installed RVM on my deployment server yet, there I just use the Bundler to make sure that all applications depend on them. I will probably also install RVM, but I have to figure out how this plays with Passenger in the first place.

As for your last question, the Bundler is a wrapper around a gem, the RVM just controls the gempath where the gems are set. It seems he is smart enough that he takes gems from the same place, although I do not need to recompile any that are already installed in some other gemset.

I stopped using sudo to set up gems after I started using RVM. There is really no reason to just install them in the rvm user path. I'm not sure of the best practice if you have more developers on the same machine as the test server, or something like that.

+3
Dec 05 '10 at
source share



All Articles