Fixing can not create client, bad configuration: did not find a proper configuration for private key

I wanted to learn how to use Terraform. I think there is no better way to learn to use a new tool than actually using it.

Oracle cloud has the always free trier so even though it's not the most popular cloud provider, I decided to give it a try and play with Terraform on it.

They prepared a step by step guide, but unfortunately, I hit an issue with this very simple case:

$ terraform plan

Error: can not create client, bad configuration: did not find a proper configuration for private key

After a bit of trial and error, I found the solution, I changed

provider "oci" {
  (...)  
  private_key_path = "$HOME/.oci/main.pem"
  (...)
}

into

provider "oci" {
  (...)  
  private_key_path = "/home/michal/.oci/main.pem"
  (...)
}

Looks like I shouldn't use env variables in the terraform files. I hope it saves somebody's time..