Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Direnv: Unclutter Your .profile (github.com/direnv)
25 points by tosh on April 4, 2022 | hide | past | favorite | 8 comments


Hi, direnv author here.

direnv is pretty old by computer standard and it's still weird for me to see it pop-up from time to time. I wrote this tool for myself and it's amazing to see it being useful to others.

Feel free to ask me anything.


Do you think Direnv is obsoleted by something else? I’ve always preferred to have an environment specific to my working directory…I seem to recall setting up similar tools for my workstations and network profiles in the 90’s. Seems like a perfectly reasonable way to work.


The next evolution is something that also sandboxes the project. A random npm library that gets installed shouldn't be allowed to access anything other than your project root.

But it also has to be fast and convenient. Docker is still too slow to fill that role.


Thank you for your amazing tool!

I would like to mention the official VS Code extension [0] for direnv.

[0]: https://marketplace.visualstudio.com/items?itemName=mkhl.dir...


I think I’ll put Direnv on my todo list and consider not using Autoenv any more. I like the way it’s able to unroll the environment, though the equivalent is possible by e.g. starting a new login shell. Is it time to stop using Bash as my interactive shell? I didn’t even realize MacOS had gone all zsh/sh on me because I long ago installed an up-to-date Bash so as not to curse so much...I enjoy my Macs but I’m starting to get all container-loving, unikernel affectionate, functions-as-a-service-friendly, commodity-hardware grasping. And there’s the constant undercurrent of Nix envy my subconscious surfaces occasionally...


I'm not sure if it's obvious but direnv also works with zsh. It's loading the .envrc with bash, then capturing the env diff, and reflecting that back to the host shell.

direnv is still back-compat with macOS's bash 3.x, although the limitation so becoming increasingly frustrating. Bash 3.x is 10y+ old at this point and it would be nice to be able to use associative arrary finally.


I've used direnv for a few years now. Especially combined with nix, it's magical how seamlessly you can navigate between very different environments!


I discovered direnv a couple of months ago and put it to work automatically switching AWS profiles. Now, when I work on CloudFormation templates for each of my AWS accounts I don't have to manually copy & paste ENVARs anymore. Thanks to direnv I just have to cd into the proper directory and BAM I have the proper credentials.

Thanx @zimbatm!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: