Error installing xk6 on macOS: both using go directly and docker

I can install k6 normally, but I cannot with xk6. I have tried it directly with go install and using docker. While the build finishes correctly in both scenarios, and both output this message:

2023-08-07 10:16:57 go: cannot match "all": go.mod file not found in current directory or any parent directory; see 'go help modules'
2023-08-07 10:16:57 2023/08/07 09:16:57 [ERROR] exec [go list -mod=readonly -m -f={{if .Replace}}{{.Path}} => {{.Replace}}{{end}} all]: exit status 1:

Shouldn’t the go.mod have been linked during build? I’m not familiar enough with go to understand what’s going on. Any help?

Hi @cyberglot

Welcome to the community forum :wave:

Let’s try to start troubleshooting generating the k6 binary with docker, can you share the output of the command:

docker run --rm -e GOOS=darwin -u "$(id -u):$(id -g)" -v "${PWD}:/xk6" \
  grafana/xk6 build v0.43.1 \
  --with github.com/mostafa/xk6-kafka@v0.17.0 \
  --with github.com/grafana/xk6-output-influxdb@v0.3.0

from the docs?

If you are seeing this error:

k6 imports
	go.k6.io/k6/cmd imports
	github.com/grafana/xk6-output-prometheus-remote/pkg/remotewrite imports
	go.buf.build/grpc/go/prometheus/prometheus: unrecognized import path "go.buf.build/grpc/go/prometheus/prometheus": https fetch: Get "https://go.buf.build/grpc/go/prometheus/prometheus?go-get=1": dial tcp: lookup go.buf.build on 192.168.65.7:53: no such host

It is due to an issue we identified last week. Try using the patched version of k6, v0.45.1:

docker run --rm -e GOOS=darwin -u "$(id -u):$(id -g)" -v "${PWD}:/xk6" \
  grafana/xk6 build v0.45.1 \
  --with github.com/mostafa/xk6-kafka@v0.17.0 \
  --with github.com/grafana/xk6-output-influxdb@v0.3.0

Does that work? If it does, we can also look at the Golang install—probably a similar issue.

Cheers!

1 Like

Hi @cyberglot

We’ve updated the documentation to reflect the changes in the commands to build extensions with docker: Build a k6 binary using Docker

Thanks for reporting this and let us know if you are still experiencing issues.

Cheers!

2 Likes

Thank you so much :yellow_heart: , the new command works.

2 Likes