openwhisk-cli icon indicating copy to clipboard operation
openwhisk-cli copied to clipboard

Failed to go build -o wsk using README.md instructions due to older client-go version

Open nitishm opened this issue 6 years ago • 8 comments

I cannot get the wsk CLI to build, following the README.md instructions page.

The go build -o wsk command fails with the following error -

go build -o wsk
# github.com/apache/incubator-openwhisk-cli/commands
commands/action.go:911:10: limits.Concurrency undefined (type *"github.com/apache/incubator-openwhisk-cli/vendor/github.com/apache/incubator-openwhisk-client-go/whisk".Limits has no field or method Concurrency)
commands/project.go:40:20: cannot use cobraCMD (type *"github.com/apache/incubator-openwhisk-cli/vendor/github.com/spf13/cobra".Command) as type *"github.com/spf13/cobra".Command in argument to cmd.Deploy
commands/project.go:51:22: cannot use cobraCMD (type *"github.com/apache/incubator-openwhisk-cli/vendor/github.com/spf13/cobra".Command) as type *"github.com/spf13/cobra".Command in argument to cmd.Undeploy
commands/project.go:63:20: cannot use cobraCMD (type *"github.com/apache/incubator-openwhisk-cli/vendor/github.com/spf13/cobra".Command) as type *"github.com/spf13/cobra".Command in argument to cmd.Deploy
commands/project.go:74:26: cannot use cobraCMD (type *"github.com/apache/incubator-openwhisk-cli/vendor/github.com/spf13/cobra".Command) as type *"github.com/spf13/cobra".Command in argument to cmd.ExportCmdImp

I can resolve the cobra errors by deleting the package from the vendor dir (not ideal), but the other issue,

go build -o wsk
# github.com/apache/incubator-openwhisk-cli/commands
commands/action.go:911:10: limits.Concurrency undefined (type *"github.com/apache/incubator-openwhisk-cli/vendor/github.com/apache/incubator-openwhisk-client-go/whisk".Limits has no field or method Concurrency)

, seems to be stemming from a mismatched client-go version.

I can see the master branch for github.com/apache/incubator-openwhisk-client-go/ now has the Concurrency field added to the Limits struct (https://github.com/apache/incubator-openwhisk-client-go/blob/master/whisk/shared.go#L100), but go get seems to fetch an older commit of the client-go library causing the build to fail.

nitishm avatar Jan 18 '19 15:01 nitishm

@nitishm, have you tried ./gradlew compile -PnativeCompile?

dubee avatar Jan 18 '19 16:01 dubee

@nitishm, have you tried ./gradlew compile -PnativeCompile?

I haven't tried that yet. I used the go get instructions to compile it myself.

nitishm avatar Jan 18 '19 17:01 nitishm

I reproduced this same error... btw, we need to nuke gradle in this repo and just use native go build it's 1000x faster.

rabbah avatar Jan 26 '19 14:01 rabbah

@nitishm bumping the hashes for the client resolves the concurrency issue:

diff --git a/vendor/vendor.json b/vendor/vendor.json
index 4a2176e..a738088 100644
--- a/vendor/vendor.json
+++ b/vendor/vendor.json
@@ -3,16 +3,16 @@
        "ignore": "test",
        "package": [
                {
-                       "checksumSHA1": "ASp79qek5lZJ18lexnxnnw8wQSs=",
+                       "checksumSHA1": "krP/Rb7hvLXzwRp+5spDj5WBk9g=",
                        "path": "github.com/apache/incubator-openwhisk-client-go/whisk",
-                       "revision": "d7cee96e83a1f38413a1f5286bd524dac72686c9",
-                       "revisionTime": "2018-08-03T16:52:51Z"
+                       "revision": "41bdfc4b124d7a9e419ba72ab19ce31f01338509",
+                       "revisionTime": "2019-01-21T12:59:58Z"
                },
                {
                        "checksumSHA1": "4NY5lFykxXaoN+JNMxo179L79sU=",
                        "path": "github.com/apache/incubator-openwhisk-client-go/wski18n",
-                       "revision": "d7cee96e83a1f38413a1f5286bd524dac72686c9",
-                       "revisionTime": "2018-08-03T16:52:51Z"
+                       "revision": "41bdfc4b124d7a9e419ba72ab19ce31f01338509",
+                       "revisionTime": "2019-01-21T12:59:58Z"
                },

rabbah avatar Jan 26 '19 14:01 rabbah

Thanks @rabbah I will try that !

nitishm avatar Jan 26 '19 15:01 nitishm

The problem comes about because of multiple references to the cobra package, including the offending duplication from wskdeploy. The compiler can't determine that the package in vendor and GOPATH are the same and hence the types do not match. The deduplication has to be occur before building and likely this requires some adjustments across this and the wskdeploy project.

rabbah avatar Jan 26 '19 18:01 rabbah

@rabbah, can this be closed now?

dubee avatar Jan 29 '19 15:01 dubee

I documented a workaround - I don't think this is the ideal solution - there's a packaging confusion between wskdeploy and the cli that should be avoided and fixed.

rabbah avatar Jan 29 '19 16:01 rabbah