No results for

Powered byAlgolia

Build a k6 binary with extensions

You might have found a neat k6 extension on the Extensions page or on GitHub and wish to use it in your tests. Great! You only need to use a k6 binary that includes the extension.

The process of building a k6 binary with one or multiple extensions is relatively simple. You'll first need to setup Go and Git. Make sure that your $PATH environment variable is updated and that go version returns the correct version.

Then install xk6 with:

go install

And confirm that which xk6 on Linux/macOS or where xk6 on Windows returns a valid path. Otherwise ensure that $GOPATH is correctly defined and that $GOPATH/bin is added to your $PATH environment variable. See the Go documentation for details.

Once xk6 is installed, building a k6 binary with one or more extensions can be done with the xk6 build command as follows:

xk6 build latest \
--with \

This will build a k6 binary in the current directory based on the most recently released k6 version including the xk6-sql and xk6-output-prometheus-remote.

... [INFO] Build environment ready
... [INFO] Building k6
... [INFO] Build complete: ./k6

Now you can run a script with this binary and use the functionalities of the bundled extensions.

./k6 my-script.js

Note that when running the script we have to specify the binary just built in the current directory (./k6), as otherwise some other k6 binary found on the system could be executed which might not have the extensions built-in. This is only the case on Linux and macOS, as Windows shells will execute the binary in the current directory first.

Also note that because of the way xk6 works, vendored dependencies (the vendor directory created by go mod vendor) will not be taken into account when building a binary, and you don't need to commit them to the extension repository.

See also