Skip to content

devlanes is in beta and not ready for production use.Report an issue

Read .env values and pin tool versions

Use this guide when a project keeps secrets or machine-specific values in a .env file, or pins its tool versions with mise or direnv, and the lanes should use both.

::example{slug="workflows-dotenv"}

The .env file sits next to the project file and stays out of Git. devlanes reads it for expressions and does not put its contents into any process, so name each variable a process needs:

devlanes.yaml
global_env:
ACME_API_TOKEN: "${{ env.ACME_API_TOKEN }}"
SENTRY_DSN: "${{ env.SENTRY_DSN | default('') }}"

Under global_env a value reaches every service and task of the lane. A variable missing from both the file and your shell stops the start, unless the expression gives a default as the second line does. A new worktree reads the primary worktree’s .env, as Files and folders describes.

~/dev/myapp
$ devlanes reload

The reload restarts the services whose values changed.

With a mise config such as mise.toml, or an allowed .envrc, in the worktree root, each service and task gets the tools and variables it sets. A config the tool does not trust yet is skipped with a note, so trust it and restart the services:

~/dev/myapp
$ mise trust
$ devlanes restart

For direnv, run direnv allow in place of mise trust.

A service that loads .env itself keeps working. Most dotenv loaders leave a variable alone when it is already set, so the value the project file passes wins.