diff --git a/command/init_test.go b/command/init_test.go index fcf0e2ec0..fdda26ea6 100644 --- a/command/init_test.go +++ b/command/init_test.go @@ -976,7 +976,8 @@ func TestInit_pluginDirReset(t *testing.T) { } // make sure we remove the plugin-dir record - if code := c.Run(nil); code != 0 { + args = []string{"-plugin-dir="} + if code := c.Run(args); code != 0 { t.Fatalf("bad: \n%s", ui.ErrorWriter) } diff --git a/command/plugins.go b/command/plugins.go index 2dce2510f..29fb0c5cc 100644 --- a/command/plugins.go +++ b/command/plugins.go @@ -113,9 +113,14 @@ func (r *multiVersionProviderResolver) ResolveProviders( // store the user-supplied path for plugin discovery func (m *Meta) storePluginPath(pluginPath []string) error { + if len(pluginPath) == 0 { + return nil + } + path := filepath.Join(m.DataDir(), PluginPathFile) - if len(pluginPath) == 0 { + // remove the plugin dir record if the path was set to an empty string + if len(pluginPath) == 1 && (pluginPath[0] == "") { err := os.Remove(path) if !os.IsNotExist(err) { return err