Auto-detect Executable File
Learn to automatically detect installed commands and lay the groundwork for filling in configuration dialogs and building custom drop downs.
Introduction
Many plugins, like the Node.js or PHP plugins, allow you to select from a list of installed interpreters. Other plugins will automatically fill out the path of an executable that is needed in their settings dialogs. In this tutorial you will learn how to auto detect the path of an executable file that can be later used for selecting an active interpreter or deciding if your plugin can run.

Prerequisites
This tutorial assumes that you already know the basics of how to create a new IntelliJ Plugin and already have a plugin project set up to modify.
Local Executable
The most common use case that you will probably come across is looking for a file that is installed on your system. This can be something in your PATH, project directory, or in a custom set of locations that is specific to the program you are trying to find.
The most common places to check are
PATH
HomeBrew
app specific version manager paths
environment variables (ex. NODIST_PREFIX)
snap packages
WSL (windows subsystem for linux)
previously saved paths (persistent state component configs)
Create a service
The first step is to create a new service manager interface that will be used to find the executable.
Create a Type for your Executable
You will want a class to wrap your executable and store metadata about it.
Searching the PATH
PATHThe PATH environment variable provides a list of directories that are automatically searched to find commands. At a minimum your plugin should support checking this variable to find your command. IntelliJ provides some useful functions to ease working with a system's PATH.
HomeBrew
Manually Entered Files
TODO
Last updated
Was this helpful?