diff --git a/command/init.go b/command/init.go index 2ab70c3960..de8b4f2454 100644 --- a/command/init.go +++ b/command/init.go @@ -302,7 +302,7 @@ func (c *InitCommand) getProviders(path string, state *terraform.State, upgrade return err } - if upgrade { + { // Purge any auto-installed plugins that aren't being used. purged, err := c.providerInstaller.PurgeUnused(chosen) if err != nil { diff --git a/command/init_test.go b/command/init_test.go index bf1d0dfca1..069f546769 100644 --- a/command/init_test.go +++ b/command/init_test.go @@ -479,6 +479,10 @@ func TestInit_getProvider(t *testing.T) { t.Fatalf("bad: \n%s", ui.ErrorWriter.String()) } + if !installer.PurgeUnusedCalled { + t.Errorf("init didn't purge providers, but should have") + } + // check that we got the providers for our config exactPath := filepath.Join(c.pluginDir(), installer.FileName("exact", "1.2.3")) if _, err := os.Stat(exactPath); os.IsNotExist(err) {