Skip to content
Advertisement

Set env variable in sudo when provisioning Vagrant

I’m trying to install a python package in a Vagrant box that runs in Ubuntu 14 with sudo, this package requires to set an env variable before.

I have tried the following commands, but it did not recognize the env variable when provisioning Vagrant: sudo AIRFLOW_GPL_UNIDECODE=yes sudo pip install apache-airflow==1.10.0 What’s the best way to set it?

Advertisement

Answer

Everything must be done with one command, else what you have done with the first command would be forgotten when the second command runs:

sudo AIRFLOW_GPL_UNIDECODE=yes pip install apache-airflow==1.10.0

Note: when using the Bourne shell, the syntax

VAR1=val1 ... VARn=valN command arg1 ... argN

… runs command arg1 ... argN with all variables VAR1, …, VARN added as its environment variables.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement