From c8445c45a9f82f56cc0eec68cbb4895b158df6a1 Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Wed, 5 Mar 2025 13:19:08 -0600 Subject: [PATCH] Add Read Existing Dot Env File Into Env Vars as a Mise TIL --- README.md | 3 +- ...ead-existing-dot-env-file-into-env-vars.md | 28 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 mise/read-existing-dot-env-file-into-env-vars.md diff --git a/README.md b/README.md index 305c478..535f203 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ pairing with smart people at Hashrocket. For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186). -_1608 TILs and counting..._ +_1609 TILs and counting..._ See some of the other learning resources I work on: - [Ruby Operator Lookup](https://www.visualmode.dev/ruby-operators) @@ -691,6 +691,7 @@ If you've learned something here, support my efforts writing daily TILs by ### Mise - [List The Files Being Loaded By Mise](mise/list-the-files-being-loaded-by-mise.md) +- [Read Existing Dot Env File Into Env Vars](mise/read-existing-dot-env-file-into-env-vars.md) ### MongoDB diff --git a/mise/read-existing-dot-env-file-into-env-vars.md b/mise/read-existing-dot-env-file-into-env-vars.md new file mode 100644 index 0000000..600b8ea --- /dev/null +++ b/mise/read-existing-dot-env-file-into-env-vars.md @@ -0,0 +1,28 @@ +# Read Existing Dot Env File Into Env Vars + +Just about any web app that I've worked on has had a `.env` file as a way of +configuring aspects of the app specific to that environment. These typically +are read into the environment with a language-specific +[dotenv](https://github.com/bkeepers/dotenv) tool. + +Mise supports this convention. In addition to specifying individual non-secret +env vars, you can also instruct `mise` to read-in a `.env` file like so: + +```toml +[env] +PORT=3344 +_.file = ".env" +``` + +The `_.file` line tells `mise` that there is a file `.env` with key-value pairs +that it should read in. It can even handle `.env.json` and `.env.toml` file +formats. + +To ensure that `mise` is picking up the values from the `.env` file, you can +run the following command and make sure they show up in the output: + +```bash +$ mise env +``` + +[source](https://mise.jdx.dev/environments/secrets.html)