Install Dotenv Linter on Ubuntu 24.04

Install Dotenv Linter on Ubuntu 24.04

Dotenv Linter is a command line tool written in Rust programming language, designed for checking and ensuring the correctness of .env files, which are commonly used in development to manage environment variables. The primary purpose of this tool is to help developers maintain clean and error-free .env files, which can often become cluttered or incorrectly formatted. This tutorial shows how to install Dotenv Linter on Ubuntu 24.04.

Install Dotenv Linter

Download the tar.gz package from the releases page of the Dotenv Linter repository:

wget -qO dotenv-linter.tar.gz https://github.com/dotenv-linter/dotenv-linter/releases/latest/download/dotenv-linter-linux-x86_64.tar.gz

Extract executable to /usr/local/bin directory:

sudo tar xf dotenv-linter.tar.gz -C /usr/local/bin dotenv-linter

Run the command to verify the Dotenv Linter version:

dotenv-linter --version

Remove the unnecessary file:

rm -rf dotenv-linter.tar.gz

Testing Dotenv Linter

Create a simple .env file for testing:

printf 'FOO=hello\nFOO=world' > .env

To use Dotenv Linter, simply run the command dotenv-linter by specifying the .env file you want to check:

dotenv-linter .env

This command will analyze the .env file for common issues and provide feedback on any errors or warnings it detects. Example:

Checking .env
.env:2 DuplicatedKey: The FOO key is duplicated
.env:2 EndingBlankLine: No blank line at the end of the file

Found 2 problems

Uninstall Dotenv Linter

To uninstall Dotenv Linter, just delete the file it's associated with:

sudo rm -rf /usr/local/bin/dotenv-linter

Leave a Comment

Cancel reply

Your email address will not be published.