Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fabric environment variables set in .bashrc are not available

I'm using Fab to deploy my application. The running of my application depends on some environment variables set in $HOME/.bashrc. However when I use fab to run the application using the below command

run("java -jar app.jar")

This application does not run as expected because the environment variables like SMTP_HOST, SMTP_PORT I set in $HOME/.bashrc are not available for this application?

I have set the env variables in $HOME/.bashrc as below

export SMTP_PORT=abc

How do I ensure the environment variables are set before I execute the run() command to run the app?

like image 822
Bourne Avatar asked Aug 25 '14 04:08

Bourne


1 Answers

You can find the following lines in .bashrc:

# If not running interactively, don't do anything
case $- in
    *i*) ;;
      *) return;;
esac

that means fabric will never source code after that block, as fabric runs your command non-interactively (in form of /bin/bash -l -c some_command)

so the simple workaround is moving export SMTP_PORT=abc to .bash_profile or .profile

like image 116
laoyur Avatar answered Sep 29 '22 09:09

laoyur