Our great sponsors
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
One of the more common practices in software projects is to keep certain information separated but accessible from the codebase which uses it. This is usually done with secrets such as passwords or private keys, but is also commonly done with user or context-specific info pieces. However, management of environment variables can be confusing. The solutions to deal with it are many, and there are even built-in ones such as bash_profile. One solution I've discovered recently and found particularly convenient is direnv, a shell extension which enables the definition of a list of environment variables scoped by a directory. After installing & hooking the extension, direnv will execute every time you change directories, looking for an .envrc file in the same or in a superior directory tree level. It will then load the defined variables to the current environment, and unload them if it ceases to detect the same .envrc. Also note that direnv will load the first detected .direnv file, which means that the environment will **not* inherit values from a .direnv in a parent directory*.