hashicorp / go-plugin

Golang plugin system over RPC.
Mozilla Public License 2.0
5.25k stars 450 forks source link

Add more helpful message on plugin setup failure #223

Closed swenson closed 1 year ago

swenson commented 1 year ago

The current error message shown when a plugin does not respond correctly can be obtuse to the end user of, for example, Vault.

Here, we add potential reasons why the plugin did not respond correctly, and some additional debugging information (provided as a best effort) including the CPU architecture that the plugin was compiled for, the current CPU architecture, and the permissions of the plugin. Hopefully this will help users diagnose why their plugin is not loading.

We also added a testdata/ directory that is optionally populated with executables in various formats to help test the additional debugging information. The binaries are over 1 MB each though, so are not checked in, and the test will be skipped if they have not been compiled.

The error message comes out looking like:

    err: Unrecognized remote plugin message: something invalid here
        This usually means
          the plugin was not compiled for this architecture,
          the plugin is missing dynamic-link libraries necessary to run,
          the plugin is not readable by this process, or
          the plugin was compiled with an incompatible version of the go-plugin protocol

        Additional notes about plugin:  Path: /var/folders/jb/4vzywqts2gl49jvwp0pz9dsc0000gq/T/go-build2701257428/b001/go-plugin.test
          Mode: -rwxr-xr-x
          MachO architecture: CpuArm64 (current architecture: arm64)
swenson commented 1 year ago

Thanks!