xo / usql

Universal command-line interface for SQL databases
MIT License
8.92k stars 351 forks source link

Darwin/amd64 binaries arent working #395

Closed sumanthkumarc closed 6 months ago

sumanthkumarc commented 1 year ago

Hi Team, Thank you for the wonderful software. It is really good and handy for using across different sql databases. I wanted to try extend usql with config file feature, with usql reading db config from file. I created a fork at https://github.com/sumanthkumarc/usql/releases/tag/v0.13.8

The binaries for the darwin/amd64 aren't working for me. I thought something wrong with my code but i tested with amd64 darwin binary from https://github.com/xo/usql/releases/tag/v0.13.8 and result is same. I keep getting the below error

zsh: exec format error: ./usql

I'm testing this on MacOS Big Sur with Intel processor.

I'll try to fix this and will update here if i succeed.

sumanthkumarc commented 1 year ago

More information -

➜ uname -a
Darwin MacBook-Pro.local 20.6.0 Darwin Kernel Version 20.6.0: Tue Oct 12 18:33:42 PDT 2021; root:xnu-7195.141.8~1/RELEASE_X86_64 x86_64

➜  wget https://github.com/xo/usql/releases/download/v0.13.8/usql-0.13.8-darwin-amd64.tar.bz2
--2023-02-10 11:06:15--  https://github.com/xo/usql/releases/download/v0.13.8/usql-0.13.8-darwin-amd64.tar.bz2
Resolving github.com (github.com)... 20.207.73.82
Connecting to github.com (github.com)|20.207.73.82|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://objects.githubusercontent.com/github-production-release-asset-2e65be/83678416/01386aef-cfeb-4d8f-b6dd-b1d223789f9d?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20230210%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20230210T053616Z&X-Amz-Expires=300&X-Amz-Signature=6e55957e40287da0ecfcdcd38fb6447cf9da480eedc4b349a6249d4f21930db2&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=83678416&response-content-disposition=attachment%3B%20filename%3Dusql-0.13.8-darwin-amd64.tar.bz2&response-content-type=application%2Foctet-stream [following]
--2023-02-10 11:06:17--  https://objects.githubusercontent.com/github-production-release-asset-2e65be/83678416/01386aef-cfeb-4d8f-b6dd-b1d223789f9d?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20230210%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20230210T053616Z&X-Amz-Expires=300&X-Amz-Signature=6e55957e40287da0ecfcdcd38fb6447cf9da480eedc4b349a6249d4f21930db2&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=83678416&response-content-disposition=attachment%3B%20filename%3Dusql-0.13.8-darwin-amd64.tar.bz2&response-content-type=application%2Foctet-stream
Resolving objects.githubusercontent.com (objects.githubusercontent.com)... 185.199.108.133, 185.199.109.133, 185.199.110.133, ...
Connecting to objects.githubusercontent.com (objects.githubusercontent.com)|185.199.108.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 25271381 (24M) [application/octet-stream]
Saving to: ‘usql-0.13.8-darwin-amd64.tar.bz2’

usql-0.13.8-darwin-amd64.tar.bz2                  100%[===========================================================================================================>]  24.10M  1.00MB/s    in 72s

2023-02-10 11:07:32 (341 KB/s) - ‘usql-0.13.8-darwin-amd64.tar.bz2’ saved [25271381/25271381]

➜   tar xvjf usql-0.13.8-darwin-amd64.tar.bz2
x usql
x LICENSE

➜  chmod +x usql

➜   ./usql
zsh: exec format error: ./usql

➜  file usql                           # Shows as data instead of executable binary!!!
usql: data

➜   file usql-0.13.8-darwin-amd64.tar.bz2    # Confirmed if the downloaded archive is in wrong format or not
usql-0.13.8-darwin-amd64.tar.bz2: bzip2 compressed data, block size = 900k
kenshaw commented 1 year ago

@sumanthkumarc I had pushed a release the other day. I've checked the binaries, and they work for me, at least. Could you do the same? Thanks.

sumanthkumarc commented 1 year ago

Sure, let me test and get back to you.

sumanthkumarc commented 1 year ago

Tried this again today @kenshaw . same result. What am i doing wrong 🤔

➜  /tmp wget https://github.com/xo/usql/releases/download/v0.13.11/usql-0.13.11-darwin-amd64.tar.bz2
--2023-03-14 16:47:01--  https://github.com/xo/usql/releases/download/v0.13.11/usql-0.13.11-darwin-amd64.tar.bz2
Resolving github.com (github.com)... 20.207.73.82
Connecting to github.com (github.com)|20.207.73.82|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://objects.githubusercontent.com/github-production-release-asset-2e65be/83678416/c8476f6d-e3fc-4b8f-b50d-bbd2dd79ac4b?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20230314%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20230314T111702Z&X-Amz-Expires=300&X-Amz-Signature=90ab844796a0ee1296cf7da15c7fb726ff1da0656cfb362428fac1a0091e544e&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=83678416&response-content-disposition=attachment%3B%20filename%3Dusql-0.13.11-darwin-amd64.tar.bz2&response-content-type=application%2Foctet-stream [following]
--2023-03-14 16:47:02--  https://objects.githubusercontent.com/github-production-release-asset-2e65be/83678416/c8476f6d-e3fc-4b8f-b50d-bbd2dd79ac4b?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20230314%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20230314T111702Z&X-Amz-Expires=300&X-Amz-Signature=90ab844796a0ee1296cf7da15c7fb726ff1da0656cfb362428fac1a0091e544e&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=83678416&response-content-disposition=attachment%3B%20filename%3Dusql-0.13.11-darwin-amd64.tar.bz2&response-content-type=application%2Foctet-stream
Resolving objects.githubusercontent.com (objects.githubusercontent.com)... 185.199.109.133, 185.199.110.133, 185.199.111.133, ...
Connecting to objects.githubusercontent.com (objects.githubusercontent.com)|185.199.109.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 26037888 (25M) [application/octet-stream]
Saving to: ‘usql-0.13.11-darwin-amd64.tar.bz2’

usql-0.13.11-darwin-amd64.tar.bz2            100%[============================================================================================>]  24.83M  2.14MB/s    in 16s

2023-03-14 16:47:20 (1.55 MB/s) - ‘usql-0.13.11-darwin-amd64.tar.bz2’ saved [26037888/26037888]

➜  /tmp tar xvjf usql-0.13.11-darwin-amd64.tar.bz2
x usql
x LICENSE

➜  /tmp chmod +x usql
➜  /tmp ./usql -h
zsh: exec format error: ./usql
➜  /tmp ./usql
zsh: exec format error: ./usql

➜  /tmp uname -a
Darwin Sumanths-Mac.local 20.6.0 Darwin Kernel Version 20.6.0: Tue Oct 12 18:33:42 PDT 2021; root:xnu-7195.141.8~1/RELEASE_X86_64 x86_64
nineinchnick commented 1 year ago

I investigated this and looks like using tar in the release workflow strips the Mach-O header from the binary. Maybe this is in combination to using the artifacts action, which is zipping the artifacts. After I switched to using zip files instead of tar.bz2 for the MacOS job, the binary works fine. @kenshaw WDYT, should we switch to using ZIP for MacOS artifacts?