TwiN / whois

Lightweight WHOIS client in Go
MIT License
7 stars 6 forks source link

bug: Missing instructions for installation using release section #4

Closed TLINDEN closed 1 year ago

TLINDEN commented 1 year ago

Describe the bug

The downloadable release is not an actual executable, go run whois.go doesn't work either and make has a problem as well.

What do you see?

When trying to execute the downloaded binary:

./whois 
./whois: line 1: syntax error near unexpected token `newline'
./whois: line 1: `!<arch>'

Because:

file whois
whois: current ar archive

Just running the go file directly doesn't work either:

go run whois.go 
package command-line-arguments is not a main package

I also tried to build it myself using the supplied toolset:

make
./scripts/build.sh
make: ./scripts/build.sh: Permission denied
make: *** [Makefile:4: build-binaries] Error 127

(execute flag is missing on the script)

Once I fixed permissions of the script, the build went ok, but produced the same non-executable ar archive. However, even trying to extract the ar archive doesn't help:

ar t whois 
__.PKGDEF
_go_.o

What do you expect to see?

Some help message for starters.

List the steps that must be taken to reproduce this issue

see above.

Version

v1.1.0

Additional information

No response

TwiN commented 1 year ago

Hello @TLINDEN, you have to unzip the archive prior to executing it.

TLINDEN commented 1 year ago

Of course did I do this. The zipe file contains an ar archive. So, again, the whole session:

% git clone https://github.com/TwiN/whois.git
Cloning into 'whois'...
remote: Enumerating objects: 109, done.
remote: Counting objects: 100% (72/72), done.
remote: Compressing objects: 100% (46/46), done.
remote: Total 109 (delta 28), reused 50 (delta 15), pack-reused 37
Receiving objects: 100% (109/109), 21.49 KiB | 3.07 MiB/s, done.
Resolving deltas: 100% (43/43), done.

% cd whois

% make
./scripts/build.sh
make: ./scripts/build.sh: Permission denied
make: *** [Makefile:4: build-binaries] Error 127

% chmod 755 scripts/build.sh 

% make
./scripts/build.sh
  adding: whois (deflated 68%)
  adding: whois (deflated 69%)
  adding: whois (deflated 67%)
  adding: whois (deflated 67%)
  adding: whois.exe (deflated 67%)

% unzip bin/whois-linux-amd64.zip
Archive:  bin/whois-linux-amd64.zip
  inflating: whois  

% file whois
whois: current ar archive

% ar t whois 
__.PKGDEF
_go_.o

It's the same with the downloadable release:

% wget https://github.com/TwiN/whois/releases/download/v1.1.0/whois-linux-amd64.zip
2022-11-22 18:49:30 (45.8 MB/s) - ‘whois-linux-amd64.zip’ saved [21891/21891]

% unzip whois-linux-amd64.zip 
Archive:  whois-linux-amd64.zip
  inflating: whois  

% ls -l whos
-rwxrwxrwx 1 scip scip   66598 Nov 11 00:14 whois*

% file whois
whois: current ar archive

% ./whois 
./whois: line 1: syntax error near unexpected token `newline'
./whois: line 1: `!<arch>'

% ar t whois 
__.PKGDEF
_go_.o

So, it seems, that cmd/whois/whois.go is not being compiled and thus not being added to the resulting binary, which explains why it's just an unready ar archive.

And if I add a syntax error to cmd/whois/whois.go, then the build runs "successfully" anyway. The file is being ignored by the build script.

Oh, the last thing I tried was (observe the size of the binary in comparision to what the release contains: 2.5M vs 66K, see ls output above):

% cd cmd/whois/

% ls -l
-rw-r--r-- 1 scip scip 354 Nov 22 19:02 whois.go

% go build

% ls -l
-rwxr-xr-x 1 scip scip 2573531 Nov 22 19:03 whois*
-rw-r--r-- 1 scip scip     354 Nov 22 19:02 whois.go

% file whois
whois: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, Go BuildID=ybXs[..]8eA, not stripped

% ./whois 
you must provide exactly one domain

So, your distributed zip file just contains the lib, not the executable. The executable is not being build nor distributed, but can be built manually in the cmd/whois subdirectory.

best regards, Tom

...

TwiN commented 1 year ago

@TLINDEN Thank you so much Tom, I've totally missed that 🤦

I've fixed the issue in d5ce6ea and updated the release assets.

Sorry again for the inconvenience 😅 Hope you have a nice day.