Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I configure Capistrano to use a different gemset for staging and production environments?
    primarykey
    data
    text
    <p>I have two files on the server, one in each environment's shared directory, named rvmrc. This contains <code>rvm use ree-1.8.7-2012.02@appname-production --create</code> for production and <code>rvm use ree-1.8.7-2012.02@appname-staging --create</code> for staging. This should allow the app to run under its own gemset, because I've built in a task to the deploy script to link the corresponding <code>shared/rvmrc</code> file into the app as <code>.rvmrc</code>. That task is displayed below, in my <code>deploy.rb</code> example.</p> <p>I still need to get bundler to use the correct gemset during the deploy, though. I thought I could do this by using <code>set :rvm_ruby_string, "ree-1.8.7-2012.02@appname-#{rails_env}"</code> to dynamically set the <code>rvm_ruby_string</code> to the environment's gemset. However, I find that my deploys only use the production gemset - even when doing <code>cap staging deploy</code>.</p> <p>See <a href="https://stackoverflow.com/questions/14004712/is-it-a-good-idea-to-use-a-different-gemset-for-staging-and-production-environme">this question</a> for more information on my thought process for even trying this (and to chime in if you think it's just a bad idea).</p> <p>What do I need to change to get my deploys to use the correct gemset based on the environment?</p> <p>In my deploy file, the relevant lines that I have (I've stripped out quite a bit) are:</p> <pre><code>require 'rvm/capistrano' require 'capistrano/ext/multistage' require 'bundler/capistrano' set :stages, %w(staging production) set :default_stage, "staging" set :rvm_ruby_string, "ree-1.8.7-2012.02@appname-#{rails_env}" set :rvm_type, :system set :bundle_without, [:development] namespace :deploy do task :rvmrc do run "rm #{latest_release}/.rvmrc; ln -s #{shared_path}/rvmrc #{latest_release}/.rvmrc" end end before "bundle:install", "deploy:rvmrc" </code></pre> <p>In my production.rb file, the relevant lines that I have (I've stripped out quite a bit) are:</p> <pre><code>set :branch, "master" set :rails_env, "production" </code></pre> <p>In my staging.rb file, the relevant lines that I have (I've stripped out quite a bit) are:</p> <pre><code>set :branch, "staging" set :rails_env, "staging" </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload