KronicDeth / intellij-elixir

Elixir plugin for JetBrain's IntelliJ Platform (including Rubymine)
Other
1.84k stars 153 forks source link

Support for direnv in iex/mix run configuration #2779

Open bhuntpenn opened 2 years ago

bhuntpenn commented 2 years ago

I've opened an issue on the intellij-better-direnv project, given how popular direnv is, would be great if Intellij just made it work but I'm not going to hold my breath waiting for that to happen :-D

https://github.com/Fapiko/intellij-better-direnv/issues/4

KronicDeth commented 2 years ago

Weirdly the JetBrains APIs for Run Configurations has support built in for an env file, but it’s not exposed in the UI component 🤷‍♀️

bhuntpenn commented 2 years ago

Weirdly the JetBrains APIs for Run Configurations has support built in for an env file, but it’s not exposed in the UI component 🤷‍♀️

Might be slightly different, in order to populate the environment variables the following needs to happen:

  1. IDE (VS Code plugin implementation) invokes direnv export json
  2. Direnv checks to see if the .envrc is in it's list of allowed .envrc files by checking for the file hash in the ~/.local/share/direnv/allow/ directory, for example:
    cat ~/.local/share/direnv/allow/252176ea588c4f353333e3c88ffad8310bcdaa8e81b86be21d3ad9b158415a37
    /Users/Bryan.Hunt/repos/secrit/.envrc
  3. If direnv finds a matching hash, it evaluates that file (the file can contain commands to in turn evaluate other files.. and takes whatever env vars have changed and outputs JSON to stdout containing all the env vars.

So... just evaluating the .env file isn't sufficient, that's just a thing from older attempts to solve this problem.