Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xk6 cannot run k6 if there is a k6 directory #45

Open
inancgumus opened this issue May 20, 2022 · 2 comments
Open

xk6 cannot run k6 if there is a k6 directory #45

inancgumus opened this issue May 20, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@inancgumus
Copy link
Member

inancgumus commented May 20, 2022

xk6 cannot run the k6 command if there is a k6 directory (or a non-executable file, I guess) in the extension folder: fork/exec ./k6: permission denied.

Reproduce:

  • git clone https://github.com/grafana/xk6-browser (or any extension)
  • cd xk6-browser
  • mkdir k6
  • xk6 run something.js

Output:

2022/05/20 15:01:55 [INFO] Temporary folder: /Users/inanc/grafana/xk6-browser/buildenv_2022-05-20-1501.2156919550
2022/05/20 15:01:55 [INFO] Writing main module: /Users/inanc/grafana/xk6-browser/buildenv_2022-05-20-1501.2156919550/main.go
2022/05/20 15:01:55 [INFO] Initializing Go module
2022/05/20 15:01:55 [INFO] exec (timeout=10s): /usr/local/go/bin/go mod init k6 
go: creating new go.mod: module k6
go: to add module requirements and sums:
        go mod tidy
2022/05/20 15:01:55 [INFO] Replace github.com/grafana/xk6-browser => /Users/inanc/grafana/xk6-browser
2022/05/20 15:01:55 [INFO] exec (timeout=0s): /usr/local/go/bin/go mod edit -replace github.com/grafana/xk6-browser=/Users/inanc/grafana/xk6-browser 
2022/05/20 15:01:55 [INFO] exec (timeout=0s): /usr/local/go/bin/go mod tidy -compat=1.17 
go: finding module for package go.k6.io/k6/cmd
go: found go.k6.io/k6/cmd in go.k6.io/k6 v0.38.3
go: finding module for package github.com/nxadm/tail
go: found github.com/nxadm/tail in github.com/nxadm/tail v1.4.8
2022/05/20 15:01:56 [INFO] Pinning versions
2022/05/20 15:01:56 [INFO] exec (timeout=0s): /usr/local/go/bin/go mod edit -require go.k6.io/k6@latest 
2022/05/20 15:01:56 [INFO] exec (timeout=0s): /usr/local/go/bin/go mod tidy -compat=1.17 
2022/05/20 15:01:56 [INFO] Build environment ready
2022/05/20 15:01:56 [INFO] Building k6
2022/05/20 15:01:56 [INFO] exec (timeout=0s): /usr/local/go/bin/go mod tidy -compat=1.17 
go: found github.com/grafana/xk6-browser in github.com/grafana/xk6-browser v0.0.0-00010101000000-000000000000
2022/05/20 15:01:56 [INFO] exec (timeout=0s): /usr/local/go/bin/go build -o /Users/inanc/grafana/xk6-browser/k6 -ldflags -w -s -trimpath 
2022/05/20 15:01:57 [INFO] Build complete: ./k6
2022/05/20 15:01:57 [INFO] Cleaning up temporary folder: /Users/inanc/grafana/xk6-browser/buildenv_2022-05-20-1501.2156919550
2022/05/20 15:01:57 [INFO] Running [./k6 run -q examples/browser_args.js]

2022/05/20 15:01:57 [ERROR] fork/exec ./k6: permission denied
@inancgumus inancgumus added the bug Something isn't working label May 20, 2022
@mstoykov
Copy link
Contributor

This seems like another facet of #3 to me 🤔

I think that apart from printing a better and earlier warning there isn't much we can do for the other case.

For xk6 run I feel like that needs a lot of work. Currently, it won't reuse a directory which means the build takes ... a while, although in reality it should be instantaneous if there are no changes or very few ones.

So I feel more like xk6 run needs to either be deprecated and users to be told to replicate what xk6 does - which is pretty simple to do either way. Or we need spend some more time to make it less slow and as this issue shows ... broken.

I don't know how common k6 directory in extensions are though ... seems rare as only you and I have hit it and I hit really early on in a really "w/e I have experimental" directory.

@inancgumus
Copy link
Member Author

inancgumus commented May 20, 2022

Oh, I missed #3 🤦

Would it be better to document that there should not be a k6 directory or file in the same directory while running xk6?

Currently, it won't reuse a directory which means the build takes ... a while, although in reality, it should be instantaneous if there are no changes or very few ones.

Yup, this is another problem. Not a biggie but it makes developing with an extension slower.

I don't know how common k6 directory in extensions is though

We've created a package named k6 for communicating with the k6 core. We could have named it core too, but making it k6 kept it concise.

In the meantime, I found a dummy solution and it works for me for now:

Update (a better version—only for zsh, though):

kbr () {
  set -o err_return
  trap "unsetopt err_return && rm -f k6x" EXIT
  xk6 build --output k6x --with github.com/grafana/xk6-browser=.
  [[ -f ./k6x ]] && ./k6x run -q "$@"
}

inancgumus added a commit to grafana/xk6-browser that referenced this issue May 30, 2022
Due to a bug in xk6 (grafana/xk6#45), we can't
have a directory or a file with a name k6.

As discussed internally, @imiric suggested renaming the k6 pkg to k6ext:
"k6ext follows the k6 convention of doing the same: errext, netext,
etc., so let's stick to that.".
inancgumus added a commit to grafana/xk6-browser that referenced this issue May 30, 2022
Due to a bug in xk6 (grafana/xk6#45), we can't
have a directory or a file with a name k6.

As discussed internally, @imiric suggested renaming the k6 pkg to k6ext:
"k6ext follows the k6 convention of doing the same: errext, netext,
etc., so let's stick to that.".
inancgumus added a commit to grafana/xk6-browser that referenced this issue May 31, 2022
Due to a bug in xk6 (grafana/xk6#45), we can't
have a directory or a file with a name k6.

As discussed internally, @imiric suggested renaming the k6 pkg to k6ext:
"k6ext follows the k6 convention of doing the same: errext, netext,
etc., so let's stick to that.".
inancgumus added a commit to grafana/xk6-browser that referenced this issue May 31, 2022
Due to a bug in xk6 (grafana/xk6#45), we can't
have a directory or a file with a name k6.

As discussed internally, @imiric suggested renaming the k6 pkg to k6ext:
"k6ext follows the k6 convention of doing the same: errext, netext,
etc., so let's stick to that.".
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants