Unable to locate(?) xk6 after installing it

Greetings again!
I have Go installed, k6 installed as well.
Go ver: 1.16.4 (latest)
k6 ver: k6 v0.31.1 ((devel), go1.16.2, darwin/arm64)

Then I’ve tried to go install github.com/k6io/xk6/cmd/xk6@latest accordingly to instruction, no errors whatsoever, everything was okay.
Yet I do receive zsh: command not found: xk6 build.
Tried to install it with binary for my system as well (mac arm64), got:
go: cannot match "all": go.mod file not found in current directory or any parent directory; see 'go help modules' 2021/06/03 18:22:52 [ERROR] exec [go list -mod=readonly -m -f={{if .Replace}}{{.Path}} => {{.Replace}}{{end}} all]: exit status 1:

Could you tell me what I might have been missing, please?
By no means I am a Go programmer, so it is quiet hard for me to find out what is actually wrong.

Here is mine go list -m all:
go: inconsistent vendoring in /Users/admin/Documents/k6: github.com/Masterminds/semver/v3@v3.1.1: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt

github.com/k6io/xk6@v0.4.1: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt

Thanks in advance!

Hi there,

go install will place the binary in the location specified by the GOBIN environment variable, which defaults to $GOPATH/bin, and GOPATH defaults to $HOME/go. So make sure these are properly set in your environment, and that $GOPATH/bin is part of your $PATH. If it’s setup correctly, which xk6 should give you the path of the executable.

That said, the error zsh: command not found: xk6 build is intriguing since it appears zsh interpreted xk6 build as a single command, which happens if you run the string "xk6 build". Otherwise the error would be command not found: xk6. Are you running xk6 from an IDE or a terminal that might be mangling the command?

1 Like

imiric,
thank you for navigating me to the real problem.
I’ve messed up with PATHs and homebrew, basically made few silly mistakes.
Issue is resolved, now I do get result after which xk6.
Thanks!

Yet I have another problem now, sadly :frowning:
So I’ve built:
xk6 build --with github.com/avitalique/xk6-file@latest
(extensions for writing to file)

It went all good, in the end I got a binary.
Then I’ve tried to ./k6 run samples/test.js, where test.js is exactly the same as in example for that extension.

As a result:
ERRO[0000] GoError: unknown module: k6/x/file at reflect.methodValueCall (native)

No idea why it didn’t work out, honestly.

This seems to be because the author of the extension isn’t using semantic versions … and there is some v0.1.1 that is cached in the go proxy server

$ curl "https://proxy.golang.org/github.com/avitalique/xk6-file/@v/list"
v0.1.1

which is before the tagged v1.2 that you need.

The fix is to run xk6 build --with github.com/avitalique/xk6-file@main

Hope this helps

edit: I opened an issue so that the repo gets properly tagged

Yes, it did work out! Thank you!

I have fixed tagging in xk6-file repo, so xk6 build --with github.com/avitalique/xk6-file@latest should work well now.

1 Like