dotenv-linter is a command-line utility for linting `.env` files, ensuring they adhere to best practices and common standards. It helps prevent syntax errors, enforce naming conventions, and identify issues like duplicate keys or incorrect line endings. The current version is `0.7.0`, with releases typically driven by new features, Python version support updates, and dependency upgrades.
pip install dotenv-linterNo compatibility data collected yet for this library.
This quickstart demonstrates how to create a simple `.env` file and then lint it using the `dotenv-linter` command-line tool. It also shows an example with a duplicate key to illustrate how the linter identifies common issues.
Upgrade your Python interpreter to 3.10 or later. Check `requires_python` in PyPI for the exact range.
Convert your `.env` files to use LF line endings. Most text editors can do this automatically. For example, in Git, ensure `core.autocrlf` is configured appropriately.
If encountering unexpected parsing issues after upgrading to 0.7.0, review your `.env` files for any non-standard syntax. The new parser might be stricter or interpret edge cases differently.
Ensure `pip install dotenv-linter` completed successfully. If using a virtual environment, activate it. Check your PATH configuration.
Convert your `.env` file to use LF (Unix-style) line endings. You can often do this in your text editor (e.g., VS Code: 'CRLF' in status bar -> 'LF'), or using `sed -i 's/\r$//' .env` on Linux/macOS.
Double-check the filename and path. Ensure the file exists in the current directory or provide the correct absolute/relative path. Also, verify file permissions.
Remove duplicate definitions of the key. Environment variables should typically be defined only once per `.env` file. The last definition often overrides previous ones, but this behavior can be inconsistent across systems.