Skip to content

fehnomenal/intellij-direnv

Repository files navigation

direnv integration for JetBrains IDEs

Build Version Downloads

This plugin provides an action to import environment variables from direnv into the Java process that is running the IDE.

Automatic Import before every Run/Debug

To automatically load the environment variables from a <project_root>/.envrc file before each and every execution of a Run/Debug configuration, visit Settings > Tools > Direnv Settings and tick the relevant checkbox.

On starting a Run/Debug job, a notification will show if the existing environment has been changed. The newly spawned process which executes the Run/Debug configuration will inherit the environment. If you often work with multiple project windows open in a single IDE instance, this is probably the best option for you.

Automatic Import on Startup

To automatically load the environment variables from a <project_root>/.envrc file when you open the project, visit Settings > Tools > Direnv Settings and tick the relevant checkbox.

If "Automatic Import on Startup" is disabled, a popup notification will appear whenever a project with a .envrc file in the root is opened. You can load the .envrc file by clicking on the link in the notification.

Manual Import

To manually load an .envrc file:

  • If you have the main toolbar enabled (View > Appearance > Main Toolbar), a button next to the Reload All from Disk action will start the process.

action-icon

  • You can also right-click on any .envrc file and click Import Direnv to load its contents.

Note: This plugin handles only .envrc files in the project root automatically, but you can use the right click method to manually import any .envrc file that is in the project directory.

Note: You need direnv in your path, or you can specify the location of your direnv executable in Settings > Tools > Direnv Settings

Installation

  • Using IDE built-in plugin system:

    Settings/Preferences > Plugins > Marketplace > Search for "intellij-direnv" > Install Plugin

  • Manually:

    Download the latest release and install it manually using Settings/Preferences > Plugins > ⚙️ > Install plugin from disk...

Building from source

git clone https://github.com/fehnomenal/intellij-direnv
cd intellij-direnv
./gradlew buildPlugin

The plugin is now in the folder build/distributions/ and can be installed manually.

On NixOS

The gradle plugins downloads JetBrains' JRE and fails to execute it. Add the following in build.gradle.kts:

tasks.withType<org.jetbrains.intellij.tasks.RunIdeBase> {
    projectExecutable.set(org.gradle.internal.jvm.Jvm.current().javaExecutable.absolutePath)
}

Logo and icon source: https://github.com/direnv/direnv-logo/tree/0949c12bafa532da0b23482a1bb042cf41b654fc


Plugin based on the IntelliJ Platform Plugin Template.