Skip to content

Conversation

@xpepper
Copy link
Contributor

@xpepper xpepper commented Jul 11, 2025

Add env_file configuration option to load environment variables from a file

Note: Please note I'm still a beginner rustacean, so I appreciate feedback both on the code's idiomaticity and expressiveness.

This PR adds a new env_file configuration option that allows loading multiple environment variables from a file, providing an alternative to specifying them individually with the existing env option.

Features

  • File-based environment loading: Use env_file = "./.env" to load variables from a file
  • Standard .env format support: Supports KEY=VALUE format with comments and quoted values
  • Flexible configuration: Can be set globally or per-job
  • Proper priority handling: Direct env variables override env_file variables
  • Relative path resolution: Paths are resolved relative to the package directory
  • Graceful error handling: Missing files generate warnings but don't fail the build

Usage Examples

Global environment file:

# bacon.toml
env_file = "./.env"

@Canop
Copy link
Owner

Canop commented Jul 12, 2025

Can you please create an issue first so that we discuss whether we want this feature and its specification ?

@xpepper
Copy link
Contributor Author

xpepper commented Jul 12, 2025

Can you please create an issue first so that we discuss whether we want this feature and its specification ?

Sure!

@xpepper
Copy link
Contributor Author

xpepper commented Jul 12, 2025

Here's the proposal @Canop #376 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants