# dotenv (Ruby)

> Loads environment variables from .env into ENV in development

Source: https://talira.ai/catalog/dotenv-ruby-rpjyc85f
Every listing: https://talira.ai/catalog.md

- Kind: Open source
- Types: Library, Command-line tool
- Categories: [libraries / configuration](https://talira.ai/categories/libraries/configuration), [developer tools / environment / env vars](https://talira.ai/categories/developer-tools/environment/env-vars), [languages / ruby](https://talira.ai/categories/languages/ruby)
- Licence: MIT[^1]
- Pricing: Free and open source[^1]
- Free tier: yes[^1]
- Backed by: [Brandon Keepers](https://talira.ai/orgs/brandon-keepers.md)

dotenv is the Ruby gem that loads environment variables from a `.env` file into `ENV` when an app boots, for development and test machines where setting them by hand isn't practical. It loads automatically in [Ruby on Rails](https://talira.ai/catalog/ruby-on-rails-xkdcpj5k.md) through dotenv-rails, and in Sinatra or plain Ruby with `require 'dotenv/load'`, reading several files in order without overwriting variables that are already set. Since 3.0 it restores `ENV` after each Rails test. It supports multi-line values, variable and command substitution, Rake tasks, and a `dotenv` command that runs a script with the variables loaded or writes a template of a `.env` file. It is MIT licensed.

## Links

- GitHub: https://github.com/bkeepers/dotenv
- Docs: https://rubydoc.info/github/bkeepers/dotenv/main

## Problems it solves

- keep API keys out of my Ruby code and load them from a file in development
- set environment variables for my Rails app locally without exporting them in my shell
- tests that change ENV leak into other tests

## Features

- loads .env files into ENV at boot
- automatic loading in Rails, with per-environment files
- restores ENV after each test
- variable and command substitution, multi-line values
- dotenv command to run scripts with the variables loaded
- creates a template of a .env file

## Trust

Overall: 0.43 out of 1.
Signals: maintenance 0.27, adoption 0.77, momentum 0.48, community 0.85, backing 0.30, extensibility 0.00.

- latest release v3.2.0 12 months ago
- 6.8k GitHub stars
- 130 contributors
- accepts sponsorship (Github)
- backed by Brandon Keepers

Warnings:

- last commit 12 months ago

## Related

- Works with [Ruby on Rails](https://talira.ai/catalog/ruby-on-rails-xkdcpj5k.md)

## Sources

[^1]: https://github.com/bkeepers/dotenv/blob/main/LICENSE (checked 27 Nov 2026)
