I want to instruct Capistrano to load environment variables that are defined on remote server. How can I do that?
It seems that when I export my environment variables inside .bashrc file, they are not taken into account by Capistrano. Capistrano seems to be executing a /usr/bin/env to create the environment for executing remote commands, but this does not seem to be loading the environment variables from .bashrc.
Let me tell you also that I am using rvm-capistrano too (just in case it might help).
Any clue?
Capistrano actually does load .bashrc. But near the top of the file you will find one of the following lines:
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
If you do any exporting after the above lines, it will not be reached by Capistrano. The solution was simply to move my setup above this line—and Capistrano works how I want.
This solution was also noted at this GitHub issue.
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