1
0
Fork 0
gaiety-life/content/tils/asdf_direnv.md
2023-09-13 11:35:21 -04:00

18 lines
No EOL
845 B
Markdown

---
title: asdf with direnv to load env variables automatically
date: 2023-06-26
---
[asdf](https://asdf-vm.com/) is a powerful tool to manage runtime versions based on the project you're in, but it can do so much more. Beyond just switching a ruby, node, elixir etc version there are plugins like [asdf-direnv](https://github.com/asdf-community/asdf-direnv#usage) which can automatically leverage the [direnv](https://direnv.net/) tool as a way to set up per-project environment variables.
```shell
asdf plugin-add direnv
asdf direnv setup --shell bash --version latest
```
Now, you may navigate to your project you need to export variables for and run `direnv allow .` and create a `.envrc` file like the following:
```shell
export FOO=BAR
```
Now the next time you change directory to this project `$FOO` should automatically be exported!