direnv setup on Ubuntu
direnv
is an extension for your shell. It augments existing shells with a new feature that can load and unload environment variables depending on the current directory.
- Load 12factor apps environment variables
- Create per-project isolated development environments
- Load secrets for deployment
- Install direnv if not installed
sudo apt-get install direnv
- Change your directory where you want to set the environment variable
cd devstack
- Set the desired variable in
.envrc
fileecho export OPENEDX_RELEASE=maple.master > .envrc
- Allow direnv
direnv allow .
- Check direnv status, whether the
.envrc
file is loaded or notdirenv status
- Add the following line at the end of your
~/.bashrc
file# Make sure it appears even after rvm, git-prompt, and other shell extensions that manipulate your prompt. eval "$(direnv hook bash)"
- Check your variable
# If this doesn't work then close the Terminal and open again and move to you directory echo ${OPENEDX_RELEASE-nope}
http://manpages.ubuntu.com/manpages/focal/man1/direnv.1.html
https://forum.opencraft.com/t/devstack-tips-and-tricks-general-discussion/65/32