Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby on Rails: Bundler & Capistrano: specify which groups (development, test) are to be excluded when deploying

The Bundler documentation says, that in order to install all necessary bundles when deploying via Capistrano, one need only insert

require 'bundler/capistrano' # siehe http://gembundler.com/deploying.html

in his deploy.rb. Then, upon deployment, Capistrano calls

  * executing "bundle install --gemfile .../releases/20110403085518/Gemfile \
    --path .../shared/bundle --deployment --quiet --without development test"

This works fine.

However, we have a staging setup on our production server, isolated from the real live site, where we test a new app release with (cloned and firewalled) live production data. There, we need test and development gems to be installed.

How do I specify the capistrano command line here? Are there parameters I can use, or do I need to set up my own capistrano task to overwrite Bundler's?

Thank you!

like image 819
Jens Avatar asked Apr 03 '11 16:04

Jens


People also ask

What is Ruby on Rails bundler?

In Rails, bundler provides a constant environment for Ruby projects by tracking and installing suitable gems that are needed. It manages an application's dependencies through its entire life, across many machines, systematically and repeatably.

Does Ruby come with bundler?

As a rule, the installed Ruby interpreter comes with Bundler installed. If not, you can install Bundler to the project SDK in one of the following ways: Select Tools | Bundler | Install Bundler from the main menu.

Does Rails come with bundler?

Rails comes with baked in support with bundler.

What is the difference between bundle and bundler?

The executables bundle & bundler have the same functionality and therefore can be used interchangeably. You can see in the bundler/exe directory that the bundler executable just loads the bundle executable. It seems to me that the bundle command is more commonly used than the bundler command.


1 Answers

Writing different tasks would certainly keep it simple:

task :production do
  # These are default settings
  set :bundle_without, [:development, :test]
end

task :staging do
  set :bundle_without, [:test]
  # set :rails_env, 'staging'
end

However, if you want to use command line options you could switch on the supplied value:

cap deploy target=staging

And inside your deploy.rb file you could use the option value as:

if target == "staging"
  set :bundle_without, [:test]
  # do other stuff here
end

There's also a more 'proper' configuration object that you can use. I've found a reference to it here: http://ryandaigle.com/articles/2007/6/22/using-command-line-parameters-w-rake-and-capistrano

like image 68
Scott Avatar answered Sep 28 '22 07:09

Scott