title: How to access environment variables during Capistrano deploy?
body: <p>I have my rails (4.2) app running through Passenger (5.0.28) + Apache (2.4.7) on an Ubuntu (14.02) system, ruby (2.3.0) managed with rbenv . I deploy with Capistrano (3.4.0). </p>
  
  <p>All my environment variables are set in a very simple <code>profile.d</code> script. </p>
  
  <pre><code>#!/bin/sh
  export VAR1=VAL1
  export VAR2=VAL2
  </code></pre>
  
  <p>This works like a charm. My app <code>ENV</code> has all the correct variables, <code>Secrets.yml</code> is properly populated... everything works EXCEPT for when deploying with Capistrano over ssh.</p>
  
  <p>In my <code>deploy.rb</code> I have the following that I think is relavant:</p>
  
  <pre><code>set :ssh_options, {
  forward_agent: true,
  paranoid: true,
  keys: "~/.ssh/id_rsa.pub"
  }
  </code></pre>
  
  <p>Capistrano docs being incredibly limited and ssh\server config not my strong point I can't seem to figure out why my <code>ENV</code> variables aren't seen by Capistrano. If I run <code>puts ENV.inspect</code> during the deploy flow, I get things such as <code>"TERM_PROGRAM"=&gt;"Apple_Terminal"</code> and my local machine user info and whatnot. Why isn't Capistrano using the remote environment? How can I amend my configuration either server side or in my deploy script to fix this?</p>
  
  <p>Thanks for the help.</p>