diff --git a/internal/command/init.go b/internal/command/init.go index 8c44b67e9f..89ab5746de 100644 --- a/internal/command/init.go +++ b/internal/command/init.go @@ -686,11 +686,12 @@ func (c *InitCommand) getProviders(ctx context.Context, config *configs.Config, // the end, by checking ctx.Err(). default: + suggestion := fmt.Sprintf("\n\nTo see which modules are currently depending on %s and what versions are specified, run the following command:\n terraform providers", provider.ForDisplay()) diags = diags.Append(tfdiags.Sourceless( tfdiags.Error, "Failed to query available provider packages", - fmt.Sprintf("Could not retrieve the list of available versions for provider %s: %s", - provider.ForDisplay(), err, + fmt.Sprintf("Could not retrieve the list of available versions for provider %s: %s%s", + provider.ForDisplay(), err, suggestion, ), )) } diff --git a/internal/command/init_test.go b/internal/command/init_test.go index 5f51b1bc45..55e8a46568 100644 --- a/internal/command/init_test.go +++ b/internal/command/init_test.go @@ -2939,6 +2939,10 @@ Error: Failed to query available provider packages Could not retrieve the list of available versions for provider hashicorp/test: no available releases match the given constraints 1.0.1, 1.0.2 + +To see which modules are currently depending on hashicorp/test and what +versions are specified, run the following command: + terraform providers ` if diff := cmp.Diff(got, want); len(diff) > 0 { t.Fatalf("wrong error message: \ngot:\n%s\nwant:\n%s\ndiff:\n%s", got, want, diff)