DEV Community

Cover image for If I Had Known Earlier, I Wouldn’t Have Struggled With .env
Thomi Jasir
Thomi Jasir

Posted on

If I Had Known Earlier, I Wouldn’t Have Struggled With .env

You know the drill. Every project has one. Database passwords, API keys, secret tokens all the private stuff that shouldn’t live in your source code. On a single machine it works fine. You create the file, put the values in, and the app runs. No drama.

The real pain starts the moment you move .env.

New laptop. New server. New teammate’s machine. Suddenly you’re copying files around, pasting secrets into Slack (then deleting the message), or worse, accidentally committing the .env to Git and feeling that cold sweat when you realize what you just did.

I lived in that cycle for about three years.

I tried everything that felt “safe enough.”

Manual copy-paste between machines.

Keeping a private note somewhere.

Even committing the file and hoping no one would notice the sensitive values (spoiler: that never feels good).

There was never a clean solution. Just workarounds that created new problems.

Then one evening I was at a Google Developer Group event. Between talks I ended up chatting with a Google developer. We were talking about everyday programming frustrations when I mentioned my long-running battle with environment files.

He laughed, not in a mean way, more like “oh, you’re still doing that?”

He told me he had stopped relying on plain .env files a long time ago. They are simply too fragile and too easy to mishandle when you work across multiple machines or with a team. He shared two main approaches people use instead:

  1. Encrypt the environment file so it can safely live in the repository and get decrypted only when needed.
  2. Use a proper secrets manager to store and retrieve credentials.

He recommended the second option, especially if you’re still figuring things out. So I decided to stop scratching my head and actually learn it.

It wasn’t instant. At the beginning it felt a bit abstract. I had to understand how secrets get stored, how applications pull them at runtime, and how to keep everything in sync across environments.

But I treated it as an investment. I didn’t want to deal with the same headache for a fourth year.

Once it clicked, everything got quieter.

Moving between machines stopped being a ritual of copying files and double-checking values. Sharing credentials with a teammate no longer meant sending sensitive text through chat.

Accidentally committing secrets became much harder to do. The system just worked in the background.

Looking back, the biggest change wasn’t the tool itself. It was the mindset shift: secrets are not something you should manually ferry from place to place. They deserve a proper home and a reliable way to travel.

I’m not saying .env files are evil. For quick local experiments or solo throwaway projects they are still perfectly fine. But the moment your work starts moving between machines, servers, or people, the manual approach starts costing more time and mental energy than it saves.

This is just a small story from one senior developer who spent too long doing things the hard way. If you’ve ever felt that same frustration, maybe it’s time to look at how you handle secrets too.

if you ask me what tools for manage secrets manager? actually i tried many things on the internet but the best that i can recommend is Dopbase secrets manager.

its easy to use and simple its like build for developer and beginner friendly.

Github: https://github.com/dopbase

I’d love to hear what works for you.

Top comments (0)