marckhouzam / cobra-completion-testing

A set of completion tests for Cobra
MIT License
4 stars 4 forks source link

fix(bash): Fix bash tests. #24

Closed JeffFaer closed 4 days ago

JeffFaer commented 7 months ago

testprog was failing with "cannot execute: required file not found". Some Google sleuthing found that it was probably because libc6 was missing.

Redhat has a similar error where it was complaining that glibc v2.32 was missing. ubi8 only seemed to be able to install v2.28, but ubi9 runs testprog without any other tweaks.

marckhouzam commented 7 months ago

Thanks @JeffFaer . Can you tell me how to reproduce the problem? On my Mac I don't see any problems when I run make bash

JeffFaer commented 7 months ago

Oh, interesting. I'm not running on a mac, so that could be it. What container engine are you using? What version of Go do you have installed?

$ uname -a
Linux 6.5.0-17-generic #17~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue Jan 16 14:32:32 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
$ docker version
Client:
 Version:           24.0.5
 API version:       1.43
 Go version:        go1.20.3
 Git commit:        24.0.5-0ubuntu1~22.04.1
 Built:             Mon Aug 21 19:50:14 2023
 OS/Arch:           linux/amd64
 Context:           default

Server:
 Engine:
  Version:          24.0.5
  API version:      1.43 (minimum version 1.12)
  Go version:       go1.20.3
  Git commit:       24.0.5-0ubuntu1~22.04.1
  Built:            Mon Aug 21 19:50:14 2023
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.7.2
  GitCommit:        
 runc:
  Version:          1.1.7-0ubuntu1~22.04.2
  GitCommit:        
 docker-init:
  Version:          0.19.0
  GitCommit:        
$ go version
go version go1.22.0 linux/amd64
marckhouzam commented 7 months ago

I tried with go 1.21.8, 1.22.0 and 1.22.1 and it worked each time.

$ uname -a
Darwin REDACTED 23.4.0 Darwin Kernel Version 23.4.0: Wed Feb 21 21:44:43 PST 2024; root:xnu-10063.101.15~2/RELEASE_ARM64_T6000 arm64
$ docker version
Client:
 Cloud integration: v1.0.31
 Version:           20.10.23
 API version:       1.41
 Go version:        go1.18.10
 Git commit:        7155243
 Built:             Thu Jan 19 17:35:19 2023
 OS/Arch:           darwin/arm64
 Context:           desktop-linux
 Experimental:      true

Server: Docker Desktop 4.17.0 (99724)
 Engine:
  Version:          20.10.23
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.18.10
  Git commit:       6051f14
  Built:            Thu Jan 19 17:31:28 2023
  OS/Arch:          linux/arm64
  Experimental:     false
 containerd:
  Version:          1.6.18
  GitCommit:        2456e983eb9e37e47538f59ea18f2043c9a73640
 runc:
  Version:          1.1.4
  GitCommit:        v1.1.4-0-g5fd4c4d
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0
$ go version
go version go1.21.8 darwin/arm64
JeffFaer commented 7 months ago

Sounds like this might be a difference between Mac and Linux then. Do you have any Linux/Ubuntu machines you can try this on?

I did manage to reproduce this on a different, Debian machine.

marckhouzam commented 7 months ago

Can provide the error you are seeing? Actually the commands leading up to the error would also help

JeffFaer commented 7 months ago
$ cd $(mktemp -d)
$ git clone https://github.com/spf13/cobra.git
$ git clone https://github.com/marckhouzam/cobra-completion-testing.git
$ cd cobra-completion-testing/
$ make bash
<output in https://gist.github.com/JeffFaer/9254a0920c2af16641edefbb4ddf8c6c>

https://gist.github.com/JeffFaer/9254a0920c2af16641edefbb4ddf8c6c

To debug this, I played around with the docker images to see why it didn't seem like anything was happening:

$ ./testprog/bin/testprog help
Usage:
  testprog [flags]
  testprog [command]
...
$ docker run -it --entrypoint /bin/bash comp-test:bash5
2f35045c85f7:/work# ./testprog/bin/testprog help
bash: ./testprog/bin/testprog: cannot execute: required file not found