Loading...
Loading...
### Terraform Version ```shell $ terraform version Terraform v1.11.4 on darwin_arm64 ``` ### Terraform Configuration Files ```terraform // terraform.tf terraform { required_providers { null = { source = "hashicorp/null" } } } ``` ### Debug Output ``` $ TF_PLUGIN_CACHE_DIR=../cache terraform -chdir=myproject init There are some problems with the CLI configuration: ╷ │ Error: The specified plugin cache dir ../cache cannot be opened: stat ../cache: no such file or directory │ ╵ As a result of the above problems, Terraform may not behave as intended. Initializing the backend... Initializing provider plugins... - Reusing previous version of hashicorp/null from the dependency lock file - Installing hashicorp/null v3.2.3... - Installed hashicorp/null v3.2.3 (signed by HashiCorp) Terraform has been successfully initialized! You may now begin working with Terraform. Try running "terraform plan" to see any changes that are required for your infrastructure. All Terraform commands should now work. If you ever set or change modules or backend configuration for Terraform, rerun this command to reinitialize your working directory. If you forget, other commands will detect it and remind you to do so if necessary. ``` ### Expected Behavior Terraform should throw no error since everything works fine. ### Actual Behavior Terraform says: ``` There are some problems with the CLI configuration: ╷ │ Error: The specified plugin cache dir ../cache cannot be opened: stat ../cache: no such file or directory │ ╵ As a result of the above problems, Terraform may not behave as intended. ``` ### Steps to Reproduce ``` $ tree -a . |-- cache `-- myproject |-- .terraform.lock.hcl `-- terraform.tf 3 directories, 2 files $ TF_PLUGIN_CACHE_DIR=../cache terraform -chdir=myproject init There are some problems with the CLI configuration: ╷ │ Error: The specified plugin cache dir ../cache cannot be opened: stat ../cache: no such file or directory │ ╵ As a result of the above problems, Terraform may not behave as intended. Initializing the backend... Initializing provider plugins... - Reusing previous version of hashicorp/null from the dependency lock file - Installing hashicorp/null v3.2.3... - Installed hashicorp/null v3.2.3 (signed by HashiCorp) Terraform has been successfully initialized! You may now begin working with Terraform. Try running "terraform plan" to see any changes that are required for your infrastructure. All Terraform commands should now work. If you ever set or change modules or backend configuration for Terraform, rerun this command to reinitialize your working directory. If you forget, other commands will detect it and remind you to do so if necessary. $ tree -a . |-- cache | `-- registry.terraform.io | `-- hashicorp | `-- null | `-- 3.2.3 | `-- darwin_arm64 | |-- LICENSE.txt | `-- terraform-provider-null_v3.2.3_x5 `-- myproject |-- .terraform | `-- providers | `-- registry.terraform.io | `-- hashicorp | `-- null | `-- 3.2.3 | `-- darwin_arm64 -> /Users/caretaker/Downloads/bug/cache/registry.terraform.io/hashicorp/null/3.2.3/darwin_arm64 |-- .terraform.lock.hcl `-- terraform.tf 15 directories, 4 files ``` ### Additional Context Both the `-chdir=` directive and `TF_PLUGIN_CACHE_DIR` work perfectly, however, Terraform shows an error in the overall configuration. My initial suspicion is that Terraform first parses and validates the configuration its given, without accounting for `-chdir`, which means it checks for `../chdir` from the current working directory, and not CWD+`-chdir`, which is why it cannot find the `../cache` directory. After validation has happened and produces the error shown above, it continues and succeeds at using `cache` as the plugin cache. My point is, this worked, so it shouldn't throw an error. ### References _No response_ ### Generative AI / LLM assisted development? _No response_
Click on a version to see all relevant bugs
Terraform Integration
Learn more about where this data comes from
Bug Scrub Advisor
Streamline upgrades with automated vendor bug scrubs
BugZero Enterprise
Wish you caught this bug sooner? Get proactive today.