grafana/xk6

Unable to run xk6 from ubuntu-latest and Mac using homebrew

horns-k opened this issue · 3 comments

Following the steps below I get an error. Both on Mac where k6 is installed via homebrew, and on ubuntu-latest image where its installed using apt-get.

cd k6_tests
go install github.com/k6io/xk6/cmd/xk6@latest (succeeds)
xk6 build master --with github.com/imiric/xk6-sql (fails with: command not found: xk6)

I feel like I am missing something super basic.

k6 run test.js reports:

ERRO[0000] GoError: unknown module: k6/x/sql
at reflect.methodValueCall (native)
at file:///Users/myusername/Documents/Repositories/k6_tests/test.js:25:22(26) hint="script exception"

(fails with: command not found: xk6)

This IMO means that you haven't configured your PATH correctly when you've installed go and the installed xk6 binary by go install github.com/k6io/xk6/cmd/xk6@latest isn't being picked up.

From the official installation instructions it seems that you may need to reopen your terminal if you installed go just for that just before using it. Other than that, I would expect that either brew or the official package would setup PATH accordingly 🤷 .

So the tr;dr is that your go install is not done, not that xk6 doesn't work.

Also xk6 does build a completely new k6 in the local directory which means that after you successfully build you will have a binary k6 in the current directory and you need to call it as ./k6 run test.js.

Hope this helps, I will keep this open in case someone can help you more and so that maybe you tell us how you fixed it ;)

Thank you for your prompt response and help.

Yes, I can confirm that this was a problem with go tooling setting env variables and not an issue with xk6.
Once I manually added $GOPATH/bin on both envs to $PATH it could find the xk6 correctly.
Seems like this behaviour, especially in regards to CI tooling has recently changed. This also failed for us on Azure DevOps pipelines, where $GOPATH/bin was set correctly, but was also not in the $PATH, we fixed it now by just changing working directory to $GOPATH/bin.

We did not see this behavior in our team when using 1.11, but for this tooling we switched to 1.16.5 which seems to behave differently with modules and also paths.

We did not see this behavior in our team when using 1.11, but for this tooling we switched to 1.16.5

That is a big jump 😅

I would expect that given that GOPATH is being deprecated the installations have started to not add it, but I would expect go install to install in a directory that by default is in the PATH and at least for me ... this is the case, also there is this issue so maybe something changed 🤷‍♂️

Either way, glad you managed to fixed. Do I understand that just starting a new terminal was not enough but you needed to manually add to $PATH? My installation (though g) added it automatically, but I would've needed to start a new terminal or . ~/.bashrc to make the change available to me.