Closed maxdeviant closed 1 year ago
This PR adds support for loading environment variables from a .env file to improve local DX.
.env
This is using my new Gleam package, glenvy for loading the file.
glenvy
When I first started hacking on packages I ran into some rather unhelpful error messages when trying to run gleam run server or gleam run sync:
packages
gleam run server
gleam run sync
exception error: #{function => <<"server">>,gleam_error => assert,line => 62, message => <<"Assertion pattern match failed">>, module => <<"packages">>, value => {error,nil}} in function packages:server/0 (/Users/maxdeviant/projects/gleam-packages/build/dev/erlang/packages/_gleam_artefacts/packages.erl, line 51)⏎
I eventually figured out that this was due to an assertion failing due to missing environment variables.
I've been using a local justfile (for just) while working on packages as a way to source the environment variables from my .env file:
justfile
just
set dotenv-load test: gleam test run: gleam run server sync: gleam run sync
Of course, I figured it would be better if we could just support .env files out of the box 🙂
Also, I totally understand if you'd rather not pull in such a green 🌱 dependency into this project.
Closing due to inactivity, please feel free to reopen
This PR adds support for loading environment variables from a
.env
file to improve local DX.This is using my new Gleam package,
glenvy
for loading the file.Motivation
When I first started hacking on
packages
I ran into some rather unhelpful error messages when trying to rungleam run server
orgleam run sync
:I eventually figured out that this was due to an assertion failing due to missing environment variables.
I've been using a local
justfile
(forjust
) while working onpackages
as a way to source the environment variables from my.env
file:Of course, I figured it would be better if we could just support
.env
files out of the box 🙂