diff --git a/config.go b/config.go index 715ce03f5..4dbb4b330 100644 --- a/config.go +++ b/config.go @@ -123,22 +123,6 @@ func (c *config) Discover() error { return nil } - // First, check whether there is a custom Plugin directory defined. This gets - // absolute preference. - if packerPluginPath := os.Getenv("PACKER_PLUGIN_PATH"); packerPluginPath != "" { - sep := ":" - if runtime.GOOS == "windows" { - // on windows, PATH is semicolon-separated - sep = ";" - } - plugPaths := strings.Split(packerPluginPath, sep) - for _, plugPath := range plugPaths { - if err := c.discoverExternalComponents(plugPath); err != nil { - return err - } - } - } - // Next, look in the same directory as the executable. exePath, err := osext.Executable() if err != nil { @@ -164,6 +148,22 @@ func (c *config) Discover() error { return err } + // Check whether there is a custom Plugin directory defined. This gets + // absolute preference. + if packerPluginPath := os.Getenv("PACKER_PLUGIN_PATH"); packerPluginPath != "" { + sep := ":" + if runtime.GOOS == "windows" { + // on windows, PATH is semicolon-separated + sep = ";" + } + plugPaths := strings.Split(packerPluginPath, sep) + for _, plugPath := range plugPaths { + if err := c.discoverExternalComponents(plugPath); err != nil { + return err + } + } + } + // Finally, try to use an internal plugin. Note that this will not override // any previously-loaded plugins. if err := c.discoverInternalComponents(); err != nil {