Is your feature request related to a problem? Please describe.
It's always kind of frustrating how I have to wait for my direnv to load before I type in my first command, as I navigate around directories with a lot of .envrc files. Frequently takes seconds and makes using a terminal kind of frustrating.
Describe the solution you'd like
Perhaps we could have an option within a .envrc file that loads up the environment in a background thread, rather than blocking on the loading. 99% of the commands I run when moving around in a bash terminal manually do not rely on the .envrc file, which takes seconds to load - perhaps there could even be a little notification letting you know when the env variables were injected.
This would ideally only apply to shell processes spawned and navigated manually, but I'm not sure how that could be implemented without introducing a lot of unintuitive complexity.
Describe alternatives you've considered
The env loading could block on only the initial command the user sends to the terminal, rather than running as a background thread.
We could just not do this.
Try to figure out why env loading is slow, and make it a lot faster.
Hi,
can you let me know a little bit more about the content of the .envrc files. For example are you always using the same use or layout command?
I think the first option is to make the .envrc loading fast before adding more complexity. I designed direnv to be fast on simple export FOO=bar type .envrc and usually it's one of the more complex stdlib functions that slow things down.
Sure. I'm using source_up, source activate xxx (conda environments), and nvm use xxx (node js environments). There's also some exports, but they're probably irrelevant
@shariq Have you considered capturing the environment with direnv dump and load it back later with direnv load? nix_use with garbage collection is a good example of how to do this, because they have the same problem.
Most helpful comment
@shariq Have you considered capturing the environment with
direnv dumpand load it back later withdirenv load? nix_use with garbage collection is a good example of how to do this, because they have the same problem.