I need to build k6 with an extension in Local


I was trying to build xk6 with an extension I’m developing in local but I’m not able to do it.

Having checked the documentation seems not to be possible: GitHub - grafana/xk6: Build k6 with extensions

I also tried this

xk6 build v0.33.0 --with github.com/simskij/xk6-chaos="/absolute/path/to/xk6-redis".

But no luck.

Does anyone tried it?

Hi! @0scar, this is possible. As long as your local set-up is correct for Golang.

Can you confirm the steps you took before the xk6 build…

Few picky things first. I noticed that you have “/absolute/path/to/xk6-redis” after your xk6-chaos, this looks incorrect to me and would be xk6 build --with github.com/grafana/xk6-chaos@latest

An example would be…

Given your Go env is set up correctly with the documented version,

go install go.k6.io/xk6/cmd/xk6@latest

and then

xk6 build --with github.com/grafana/xk6-chaos@latest

you can then run the binary with

./k6 run .....

Hi, @chris.kempster

Many thanks for the answer. Maybe I didn’t explain properly: I’m trying to build using my “local extension”

The Build Bundler linked above only works for published extensions. If you’re developing your own extension or modifying one locally, you will need to build a custom binary of k6 using your local extension rather than the published version.

If you’re creating a new extension, run this:

xk6 build v0.32.0 --with /Users/nic/git/xk6-myextension

If you’re modifying a published extension:

xk6 build v0.32.0 --with github.com/simskij/xk6-chaos="/Users/nic/git/xk6-chaos"