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

Add -buildvcs=false build option #48

Closed
amelkikh opened this issue Sep 16, 2022 · 5 comments · Fixed by #51
Closed

Add -buildvcs=false build option #48

amelkikh opened this issue Sep 16, 2022 · 5 comments · Fixed by #51

Comments

@amelkikh
Copy link

Hi!
There is an error occurred while run build command

$ uname 
5.4.0-125-generic #141-Ubuntu SMP Wed Aug 10 13:42:03 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
$ go version
go version go1.19.1 linux/amd64
$ xk6 build v0.40.0 --with github.com/grafana/xk6-output-prometheus-remote
2022/09/16 20:42:36 [INFO] Temporary folder: /tmp/buildenv_2022-09-16-2042.2109028401
2022/09/16 20:42:36 [INFO] Initializing Go module
2022/09/16 20:42:36 [INFO] exec (timeout=10s): /usr/local/go/bin/go mod init k6 
go: creating new go.mod: module k6
2022/09/16 20:42:36 [INFO] Pinning versions
2022/09/16 20:42:36 [INFO] exec (timeout=0s): /usr/local/go/bin/go mod edit -require github.com/grafana/xk6-output-prometheus-remote@latest 
2022/09/16 20:42:36 [INFO] exec (timeout=0s): /usr/local/go/bin/go mod tidy -compat=1.17 
2022/09/16 20:42:37 [INFO] exec (timeout=0s): /usr/local/go/bin/go mod tidy -compat=1.17 
2022/09/16 20:42:37 [INFO] Writing main module: /tmp/buildenv_2022-09-16-2042.2109028401/main.go
2022/09/16 20:42:37 [INFO] exec (timeout=0s): /usr/local/go/bin/go mod edit -require go.k6.io/k6@v0.40.0 
2022/09/16 20:42:37 [INFO] exec (timeout=0s): /usr/local/go/bin/go mod tidy -compat=1.17 
2022/09/16 20:42:37 [INFO] exec (timeout=0s): /usr/local/go/bin/go mod tidy -compat=1.17 
2022/09/16 20:42:38 [INFO] Build environment ready
2022/09/16 20:42:38 [INFO] Building k6
2022/09/16 20:42:38 [INFO] exec (timeout=0s): /usr/local/go/bin/go mod tidy -compat=1.17 
2022/09/16 20:42:38 [INFO] exec (timeout=0s): /usr/local/go/bin/go build -o /tmp/k6 -ldflags -w -s -trimpath 
error obtaining VCS status: exit status 128
	Use -buildvcs=false to disable VCS stamping.
2022/09/16 20:42:38 [INFO] Cleaning up temporary folder: /tmp/buildenv_2022-09-16-2042.2109028401
2022/09/16 20:42:38 [FATAL] exit status 1
@mstoykov
Copy link
Contributor

Hi @amelkikh, Thanks for reporting this 🙇

Can you confirm that you are using Ubuntu 18.04 and what your git version is?

This seems to be related to golang/go#51253

I personally will prefer if -buildvcs=false isn't the default so maybe we can try to fix it by implementing #4 and letting users using old version of git to fix this themselves 🤔

@amelkikh
Copy link
Author

Hi!

$ git version
git version 2.25.1
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.4 LTS
Release:        20.04
Codename:       focal

@amelkikh
Copy link
Author

I have an idea to check Go version at runtime and add different behavior for version < 1.18 also add additional github actions to check builds with Go versions matrix.
What do you think about that idea?

@mstoykov
Copy link
Contributor

Sorry for the slow response, this kind of fell through the cracks and I had a few days off. 🙇

I have an idea to check Go version at runtime and add different behavior for version < 1.18 also add additional github actions to check builds with Go versions matrix.

I did have similar idea for the previous time we wanted to do different things with different go versions, but:

  1. This won't be as easy and one of the main benefits of the xk6 approach of extensions was that all parts of it are simpler as possible. When I previously looked into it - this change will likely double if not triple the complexity of xk6
  2. (probably more importantly) Due to the fact that golang supports only the last 2 versions and k6 in practice also only supports the last 2 versions of golang - supporting older versions is not really a priority. We likely will soon start using generics and even if we don't I am pretty sure we are now requiring 1.17 and we will likely bump that to 1.18 with something other than 1.18. And this will continue to be the case. So even if xk6 could do different things - it still won't matter as it won't be able to build the final binary as we would need higher versions for the actual source code.

I am also pretty certain this has very little to do with the actual go version - yes if you use older version of go it likely won't add the VCS data and as such won't use the git flag that is apperantly missing 🤷

I also don't know how old of a git version it needs but 2.25.1 seems ... close enough.

Can you try to build something with just pure go and see what it says - maybe the error then will be more understandable 🤔

Ultimately implementing #4 will let you set whatever(or at least most) flags you need to fix or change the way xk6 builds. So this is definitely the superiour solution IMO.

If you are interested - go for it, but otherwise I don't know when I or somebody else will have time to do it :(

@mstoykov
Copy link
Contributor

Hm ... I just tested in a docker container with Ubuntu 20.04 and it worked for me - I had to download the 1.19.1 from golang.org and play with PATH (as the one included with ubuntu is 1.13).

No idea why yours didn't work 🤔

Are you sure that /usr/local/go/bin/go is 1.19.1 ?

@imiric imiric linked a pull request Nov 11, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants