The command I use is executed from the project folder where the plugin binary is present:
$ PACKER_PLUGIN_PATH=$PWD packer build empty.pkr.hcl
Error: Unknown source type image-builder
on empty.pkr.hcl line 4:
(source code not available)
The source image-builder is unknown by Packer, and is likely part of a plugin
that is not installed.
You may find the needed plugin along with installation instructions documented
on the Packer integrations page.
https://developer.hashicorp.com/packer/integrations?filter=image
I am on SDK 0.5.2 because of SDK issue no 187 and the OS is Fedora 41 with the official Packer build version Packer v1.11.2. Thanks for help.
2025/01/28 08:46:45 [INFO] Packer version: 1.11.2 [go1.21.12 linux amd64]
2025/01/28 08:46:45 [INFO] PACKER_CONFIG env var not set; checking the default config file path
2025/01/28 08:46:45 [INFO] PACKER_CONFIG env var set; attempting to open config file: /home/lzap/.packerconfig
2025/01/28 08:46:45 [WARN] Config file doesn't exist: /home/lzap/.packerconfig
2025/01/28 08:46:45 [INFO] Setting cache directory: /home/lzap/.cache/packer
2025/01/28 08:46:45 [TRACE] listing potential installations for <nil> that match "". plugingetter.ListInstallationsOptions{PluginDirectory:"/home/lzap/packer-plugin-image-builder", BinaryInstallationOptions:plugingetter.BinaryInstallationOptions{APIVersionMajor:"5", APIVersionMinor:"0", OS:"linux", ARCH:"amd64", Ext:"", Checksummers:[]plugingetter.Checksummer{plugingetter.Checksummer{Type:"sha256", Hash:(*sha256.digest)(0xc0008dc080)}}, ReleasesOnly:false}}
2025/01/28 08:46:45 ui error: Error: Unknown source type image-builder
When I install the plugin it works, packer is just not picking it up from the PWD for some reason. I double checked it is executable, I can run it, it reports metadata just fine.
I did research the code logic around loading plugins and it seems that the statement in docs that one can simply load plugins from a current directory by overriding PACKER_PLUGIN_PATH is not correct.
If you want to load a custom build of a plugin the following conditions must match:
Plugin name must now contain the API version, OS architecture and name and SHA sum.
There must be a SHASUM file next to the plugin file with a suffix
Must not be in a root directory that was passed via PACKER_PLUGIN_PATH
Here is an example of a Makefile that builds a plugin and prepares the environment in a way that one can execute it via make start:
The important trick is to create subdirectory ./build/plugins and build the executable there into correct form with underscores and then creating SHA256SUM suffixed file as well. Only then packer appears to load it.