Skip to content

docs: windows plugin development #2334

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Netkracker
Copy link

@Netkracker Netkracker commented Jun 17, 2025

Updating docs for plugin development. Docs seem to be wrong for windows systems.

.tflint.hcl

plugin "azurerm" {
    enabled = true
    version = "0.28.0"
    source  = "github.com/terraform-linters/tflint-ruleset-azurerm"
}

plugin "terraform" {
    enabled = true
    version = "0.12.0"
    source  = "github.com/terraform-linters/tflint-ruleset-terraform"
}

plugin "postch" {
  enabled = true
}

Placing local plugin into directory defined in docs
image

tflint debug

12:06:40 runner.go:47: [INFO] Initialize new runner for root
12:06:40 discovery.go:90: [DEBUG] Find plugin path: C:\Users\SamAccountName\.tflint.d\plugins\github.com\terraform-linters\tflint-ruleset-azurerm\0.28.0\tflint-ruleset-azurerm.exe
12:06:40 discovery.go:54: [INFO] Plugin "azurerm" found
12:06:40 [DEBUG] cmdrunner/cmd_runner.go:73: starting plugin: path=C:\Users\SamAccountName\.tflint.d\plugins\github.com\terraform-linters\tflint-ruleset-azurerm\0.28.0\tflint-ruleset-azurerm.exe args=["C:\\Users\\SamAccountName\\.tflint.d\\plugins\\github.com\\terraform-linters\\tflint-ruleset-azurerm\\0.28.0\\tflint-ruleset-azurerm.exe"]
12:06:40 [DEBUG] cmdrunner/cmd_runner.go:80: plugin started: path=C:\Users\SamAccountName\.tflint.d\plugins\github.com\terraform-linters\tflint-ruleset-azurerm\0.28.0\tflint-ruleset-azurerm.exe pid=22628
12:06:40 [DEBUG] [email protected]/client.go:827: waiting for RPC address: plugin=C:\Users\SamAccountName\.tflint.d\plugins\github.com\terraform-linters\tflint-ruleset-azurerm\0.28.0\tflint-ruleset-azurerm.exe  
12:06:40 [DEBUG] [email protected]/client.go:1216: tflint-ruleset-azurerm.exe: 12:06:40 [DEBUG] [email protected]/server.go:419: plugin address: network=tcp address=127.0.0.1:10000
12:06:40 [DEBUG] [email protected]/client.go:880: using plugin: version=11
12:06:40 discovery.go:90: [DEBUG] Find plugin path: C:\Users\SamAccountName\.tflint.d\plugins\github.com\terraform-linters\tflint-ruleset-terraform\0.12.0\tflint-ruleset-terraform.exe
12:06:40 discovery.go:54: [INFO] Plugin "terraform" found
12:06:40 [DEBUG] cmdrunner/cmd_runner.go:73: starting plugin: path=C:\Users\SamAccountName\.tflint.d\plugins\github.com\terraform-linters\tflint-ruleset-terraform\0.12.0\tflint-ruleset-terraform.exe args=["C:\\Users\\SamAccountName\\.tflint.d\\plugins\\github.com\\terraform-linters\\tflint-ruleset-terraform\\0.12.0\\tflint-ruleset-terraform.exe"]
12:06:40 [DEBUG] cmdrunner/cmd_runner.go:80: plugin started: path=C:\Users\SamAccountName\.tflint.d\plugins\github.com\terraform-linters\tflint-ruleset-terraform\0.12.0\tflint-ruleset-terraform.exe pid=23204
12:06:40 [DEBUG] [email protected]/client.go:827: waiting for RPC address: plugin=C:\Users\SamAccountName\.tflint.d\plugins\github.com\terraform-linters\tflint-ruleset-terraform\0.12.0\tflint-ruleset-terraform.exe
12:06:40 [DEBUG] [email protected]/client.go:1216: tflint-ruleset-terraform.exe: 12:06:40 [DEBUG] [email protected]/server.go:419: plugin address: network=tcp address=127.0.0.1:10001
12:06:40 [DEBUG] [email protected]/client.go:880: using plugin: version=11
Failed to initialize plugins; Plugin "postch" not found in C:\Users\SamAccountName\.tflint.d\plugins

Placing local plugin directly into to the plugin folder without further subfolders
image
tflint debug

12:16:34 runner.go:47: [INFO] Initialize new runner for root
12:16:34 discovery.go:90: [DEBUG] Find plugin path: C:\Users\SamAccountName\.tflint.d\plugins\github.com\terraform-linters\tflint-ruleset-azurerm\0.28.0\tflint-ruleset-azurerm.exe
12:16:34 discovery.go:54: [INFO] Plugin "azurerm" found
12:16:34 [DEBUG] cmdrunner/cmd_runner.go:73: starting plugin: path=C:\Users\SamAccountName\.tflint.d\plugins\github.com\terraform-linters\tflint-ruleset-azurerm\0.28.0\tflint-ruleset-azurerm.exe args=["C:\\Users\\SamAccountName\\.tflint.d\\plugins\\github.com\\terraform-linters\\tflint-ruleset-azurerm\\0.28.0\\tflint-ruleset-azurerm.exe"]
12:16:34 [DEBUG] cmdrunner/cmd_runner.go:80: plugin started: path=C:\Users\SamAccountName\.tflint.d\plugins\github.com\terraform-linters\tflint-ruleset-azurerm\0.28.0\tflint-ruleset-azurerm.exe pid=13636       
12:16:34 [DEBUG] [email protected]/client.go:827: waiting for RPC address: plugin=C:\Users\SamAccountName\.tflint.d\plugins\github.com\terraform-linters\tflint-ruleset-azurerm\0.28.0\tflint-ruleset-azurerm.exe  
12:16:34 [DEBUG] [email protected]/client.go:1216: tflint-ruleset-azurerm.exe: 12:16:34 [DEBUG] [email protected]/server.go:419: plugin address: network=tcp address=127.0.0.1:10002
12:16:34 [DEBUG] [email protected]/client.go:880: using plugin: version=11
12:16:34 discovery.go:90: [DEBUG] Find plugin path: C:\Users\SamAccountName\.tflint.d\plugins\github.com\terraform-linters\tflint-ruleset-terraform\0.12.0\tflint-ruleset-terraform.exe
12:16:34 discovery.go:54: [INFO] Plugin "terraform" found
12:16:34 [DEBUG] cmdrunner/cmd_runner.go:73: starting plugin: path=C:\Users\SamAccountName\.tflint.d\plugins\github.com\terraform-linters\tflint-ruleset-terraform\0.12.0\tflint-ruleset-terraform.exe args=["C:\\Users\\SamAccountName\\.tflint.d\\plugins\\github.com\\terraform-linters\\tflint-ruleset-terraform\\0.12.0\\tflint-ruleset-terraform.exe"]
12:16:34 [DEBUG] cmdrunner/cmd_runner.go:80: plugin started: path=C:\Users\SamAccountName\.tflint.d\plugins\github.com\terraform-linters\tflint-ruleset-terraform\0.12.0\tflint-ruleset-terraform.exe pid=21220   
12:16:34 [DEBUG] [email protected]/client.go:827: waiting for RPC address: plugin=C:\Users\SamAccountName\.tflint.d\plugins\github.com\terraform-linters\tflint-ruleset-terraform\0.12.0\tflint-ruleset-terraform.exe
12:16:34 [DEBUG] [email protected]/client.go:880: using plugin: version=11
12:16:34 [DEBUG] [email protected]/client.go:1216: tflint-ruleset-terraform.exe: 12:16:34 [DEBUG] [email protected]/server.go:419: plugin address: network=tcp address=127.0.0.1:10003
12:16:34 discovery.go:90: [DEBUG] Find plugin path: C:\Users\SamAccountName\.tflint.d\plugins\tflint-ruleset-postch.exe
12:16:34 discovery.go:54: [INFO] Plugin "postch" found
12:16:34 [DEBUG] cmdrunner/cmd_runner.go:73: starting plugin: path=C:\Users\SamAccountName\.tflint.d\plugins\tflint-ruleset-postch.exe args=["C:\\Users\\SamAccountName\\.tflint.d\\plugins\\tflint-ruleset-postch.exe"] 
12:16:35 [DEBUG] cmdrunner/cmd_runner.go:80: plugin started: path=C:\Users\SamAccountName\.tflint.d\plugins\tflint-ruleset-postch.exe pid=17556
12:16:35 [DEBUG] [email protected]/client.go:827: waiting for RPC address: plugin=C:\Users\SamAccountName\.tflint.d\plugins\tflint-ruleset-postch.exe
12:16:35 [DEBUG] [email protected]/client.go:1216: tflint-ruleset-postch.exe: 12:16:35 [DEBUG] [email protected]/server.go:419: plugin address: network=tcp address=127.0.0.1:10004
12:16:35 [DEBUG] [email protected]/client.go:880: using plugin: version=11
12:16:35 [DEBUG] host2plugin/client.go:124: starting host-side gRPC server
12:16:35 [DEBUG] host2plugin/client.go:124: starting host-side gRPC server
12:16:35 [DEBUG] host2plugin/client.go:124: starting host-side gRPC server
12:16:35 [DEBUG] [email protected]/grpc_stdio.go:142: stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
12:16:35 [INFO]  [email protected]/client.go:780: plugin process exited: plugin=C:\Users\SamAccountName\.tflint.d\plugins\github.com\terraform-linters\tflint-ruleset-azurerm\0.28.0\tflint-ruleset-azurerm.exe id=13636
12:16:35 [DEBUG] [email protected]/client.go:558: plugin exited
12:16:35 [DEBUG] [email protected]/grpc_stdio.go:142: stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
12:16:35 [INFO]  [email protected]/client.go:780: plugin process exited: plugin=C:\Users\SamAccountName\.tflint.d\plugins\github.com\terraform-linters\tflint-ruleset-terraform\0.12.0\tflint-ruleset-terraform.exe id=21220
12:16:35 [DEBUG] [email protected]/client.go:558: plugin exited
12:16:35 [DEBUG] [email protected]/grpc_stdio.go:142: stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
12:16:35 [INFO]  [email protected]/client.go:780: plugin process exited: plugin=C:\Users\SamAccountName\.tflint.d\plugins\tflint-ruleset-postch.exe id=17556
12:16:35 [DEBUG] [email protected]/client.go:558: plugin exited
3 issue(s) found:

using tflint 0.58.0
image


Thus, with the configuration above where the plugin name is "foo", the executable must be named tflint-ruleset-foo (or tflint-ruleset-foo.exe on Windows). So you should move the binary into the plugin directory in advance.

**Important for Windows Users:** On Windows, make sure to place the executable directly into the plugins folder (e.g. C:\Users\\[username]\\.tflint.d\plugins\) without using any subfolders. This direct placement is required for TFLint to detect and load the plugin correctly.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this sentence necessary? I don't think there is any difference between Windows and Unix, except for the .exe extension in the file name.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree can remove "Important for Windows Users:" the other clarification sentence would have helped me to figure out my problem faster. WDYT ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally, I think this sentence should be removed altogether.

I understand that your misunderstanding arose because it was unclear in the original sentence whether "(For instance, ~/.tflint.d/plugins/tflint-ruleset-[name])" referred to "the plugin directory" or "binary in the plugin directory".

Since the revised sentence does not contain this ambiguity, I do not think it is necessary to emphasize this issue so much.

@@ -104,7 +104,11 @@ plugin "foo" {
}
```

When the plugin is enabled, TFLint invokes the `tflint-ruleset-[name]` (`tflint-ruleset-[name].exe` on Windows) binary in the plugin directory (For instance, `~/.tflint.d/plugins/tflint-ruleset-[name]`). So you should move the binary into the directory in advance.
When enabled, TFLint looks for the plugin binary following the pattern tflint-ruleset-\[name] (or tflint-ruleset-\[name].exe on Windows) directly in your plugins folder (e.g., ~/.tflint.d/plugins/ on Unix-like systems or C:\Users\\[username]\\.tflint.d\plugins\ on Windows).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the way, to be honest, there is an issue with the location of files in Windows...
It should probably be placed in %APPDATA%/tflint.d/plugins like Terraform.
https://developer.hashicorp.com/terraform/cli/config/config-file#implied-local-mirror-directories

@bendrucker bendrucker changed the title chore: correct user-guide for plugins and make them more understandable docs: windows plugin development Jun 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants