I'm deploying a rails app to a VPS with capistrano, bundler and rvm. Here is part of my deploy.rb
$:.unshift(File.expand_path('./lib', ENV['rvm_path']))
require "rvm/capistrano"
require "bundler/capistrano" # Load RVM's capistrano plugin.
set :rvm_type, :system
set :rvm_ruby_string, '1.9.2@gemset_name'
my .rvmrc
rvm --create use 1.9.2@gemset_name
When I logged into the server I noticed that the rvm gemset was created, however all the gems were installed in /shared/bundle/ruby/1.9.1/gems --not in the gemset(/usr/local/rvm/gemset)
I use RVM in development and I think it's great but when is time to deploy to production. what are the best practices? Is there a way to tell bundler to install the gems in the gemset?
Do I even need a gemset at all? (seems like bundler is already isolating gemsets), Am I missing something?
Please help me understand!
Thank you very much
Gemsets are little libraries for individual projects, where each gem used in the project is stored. You tell Ruby which gems you need for a project, and it stores them in a gemset so you can quickly switch project to project and have all the gems you need (and only the gems you need for each project).
∞RVM PackagesThis functionality has been deprecated by autolibs which is now enabled by default, however if you still need it - it is there.
RVM is easier to install than Rbenv, RVM has more features than Rbenv, RVM includes a built-in Ruby installation mechanism while Rbenv does not.
gem env – try to search in provided list under GEM PATHS, in specifications/default. remove there bundler-VERSION. gemspec. install bundler, if you don't have specific: gem install bundler:VERSION --default.
I use RVM in development and production as well. However, while I use gemsets in development to separate gems between my rails projects, I only use RVM to install rubies on my production VPS and let Bundler handle the versions of my gems.
Using the bundler integration via require "bundler/capistrano"
automatically sets some things up for bundler. You can see the code behind this in Bundlers Github page. The basic settings are so that bundle executes this command:
bundle install --gemfile Gemfile --path shared/bundle --deployment --quiet --without development test
As you can see, the --deployment
and --path
flags are given, which tells Bundler to bundle your gems with your application in the shared/bundle
directory, and only use the versions specified in your Gemfile.lock (i.e. the versions that are working in development). Since the bundle directory is shared between deployments, I find it comparable to using RVM gemsets for each application, just easier.
If you still want to put gems in separate gemsets I'd recommend this tutorial from Darcy Laycock for further reading.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With