@@ -2,6 +2,7 @@ package command
22
33import (
44 "encoding/json"
5+ "errors"
56 "fmt"
67 "io/ioutil"
78 "log"
@@ -45,27 +46,42 @@ func (r *multiVersionProviderResolver) ResolveProviders(
4546 var errs []error
4647
4748 chosen := choosePlugins (r .Available , reqd )
48- for name := range reqd {
49+ for name , req := range reqd {
4950 if newest , available := chosen [name ]; available {
5051 digest , err := newest .SHA256 ()
5152 if err != nil {
5253 errs = append (errs , fmt .Errorf ("provider.%s: failed to load plugin to verify its signature: %s" , name , err ))
5354 continue
5455 }
5556 if ! reqd [name ].AcceptsSHA256 (digest ) {
56- // This generic error message is intended to avoid troubling
57- // users with implementation details. The main useful point
58- // here is that they need to run "terraform init" to
59- // fix this, which is covered by the UI code reporting these
60- // error messages.
61- errs = append (errs , fmt .Errorf ("provider.%s: installed but not yet initialized" , name ))
57+ errs = append (errs , fmt .Errorf ("provider.%s: new or changed plugin executable" , name ))
6258 continue
6359 }
6460
6561 client := tfplugin .Client (newest )
6662 factories [name ] = providerFactory (client )
6763 } else {
68- errs = append (errs , fmt .Errorf ("provider.%s: no suitable version installed" , name ))
64+ msg := fmt .Sprintf ("provider.%s: no suitable version installed" , name )
65+
66+ required := req .Versions .String ()
67+ // no version is unconstrained
68+ if required == "" {
69+ required = "(any version)"
70+ }
71+
72+ foundVersions := []string {}
73+ for meta := range r .Available .WithName (name ) {
74+ foundVersions = append (foundVersions , fmt .Sprintf ("%q" , meta .Version ))
75+ }
76+
77+ found := "none"
78+ if len (foundVersions ) > 0 {
79+ found = strings .Join (foundVersions , ", " )
80+ }
81+
82+ msg += fmt .Sprintf ("\n version requirements: %q\n versions installed: %s" , required , found )
83+
84+ errs = append (errs , errors .New (msg ))
6985 }
7086 }
7187
0 commit comments