Environment :
The problem :
I have a git hook pre-commit
set globally like this :
git config --global core.hooksPath <PATH_TO_HOOK_FILE>
In this git hook I call terraform commands like this :
terraform fmt
terraform init
terraform plan
I have installed terraform with homebrew.
In my terminal inside ANY git project on my machine, when I try to commit, everything works like a charm :
git commit -m "My commit message"
inventories.tf
module.tf
Success! The configuration is valid.
[main 559149a] My commit message
3 file changed, 6 insertion(+), 5 deletion(-)
But when I am using IntelliJ Idea
-> Commit view
to commit I am having this error :
/home/.../pre-commit: line 57: terraform: command not found
When I change it to the full path of the command (i.e. /toto/titi/terraform) inside the hooks file it works.
So my question is : How can I tell IntelliJ where is Terraform executable ?
I've already tried setting the full path in Settings
-> Tools
-> Terraform
(not working) and even selecting "Terraform fmt" in Commits option does not work.
EDIT :
As pointed out by Dino Letic, the issue was that IntelliJ need to load terminal environment variable (which I thought was done automatically).
To fix this, either start it in a terminal or simply install it using IntelliJ toolbox if you prefer starting it as an application.
EDIT 2 :
IntelliJ, when started as an application and not from the terminal, uses the ~/.profile to load variables like PATH.
Simply edit the file to add your binary path to the PATH variable and your all set :
export PATH=$PATH:<PATH_TO_YOUR_BINS>
Ide should inherit env variables from default terminal. If these paths are detected in terminal, can you start IDE inside terminal, does it work?