golangci / golangci-lint

Fast linters runner for Go
https://golangci-lint.run
GNU General Public License v3.0
14.84k stars 1.34k forks source link

Install script `unable to find` on windows + latest curl (v8.8.0) #4813

Closed Adjective-Object closed 2 weeks ago

Adjective-Object commented 2 weeks ago

Welcome

Description of the problem

Installation of golangci-lint is failing in one of my project's windows CI.

This reproduces for all requested installed versions, including latest.

I did some digging in by downloading the install script and adding some debug statements; it looks like the problem comes down to the use of curl -w in http_download_curl:

$ curl -w '%{http_code}' -sL -H "$header" https://github.com/golangci/golangci-lint/releases/v1.59.1
000

The same curl command works without -w, and 000 isn't a valid response code. I did some poking around:

$ curl -w '%{json}' -sL -H "$header" https://github.com/golangci/golangci-lint/releases/v1.59.1
{"certs":"Subject:CN=github.com\nIssuer:C=GB, ST=Greater Manchester, L=Salford, O=Sectigo Limited, CN=Sectigo ECC Domain Validation Secure Server CA\nVersion:2\nSerial Number:4e:28:f7:86:b6:6c:1a:3b:94:2c:d2:c4:0e:b7:42:a5:\n","content_type":null,"conn_id":0,"errormsg":"A libcurl function was given a bad argument","exitcode":43,"filename_effective":null,"ftp_entry_path":null,"http_code":0,"http_connect":0,"http_version":"0","local_ip":"172.20.20.20","local_port":55312,"method":"GET","num_certs":3,"num_connects":1,"num_headers":0,"num_redirects":0,"proxy_ssl_verify_result":0,"proxy_used":0,"redirect_url":null,"referer":null,"remote_ip":"140.82.112.3","remote_port":443,"response_code":0,"scheme":"https","size_download":0,"size_header":0,"size_request":0,"size_upload":0,"speed_download":0,"speed_upload":0,"ssl_verify_result":0,"time_appconnect":0.000000,"time_connect":0.131360,"time_namelookup":0.035237,"time_pretransfer":0.000000,"time_redirect":0.000000,"time_starttransfer":0.000000,"time_total":0.232505,"url":"https://github.com/golangci/golangci-lint/releases/v1.59.1","url.scheme":"https","url.user":null,"url.password":null,"url.options":null,"url.host":"github.com","url.port":"443","url.path":"/golangci/golangci-lint/releases/v1.59.1","url.query":null,"url.fragment":null,"url.zoneid":null,"urle.scheme":"https","urle.user":null,"urle.password":null,"urle.options":null,"urle.host":"github.com","urle.port":"443","urle.path":"/golangci/golangci-lint/releases/v1.59.1","urle.query":null,"urle.fragment":null,"urle.zoneid":null,"url_effective":"https://github.com/golangci/golangci-lint/releases/v1.59.1","urlnum":0,"xfer_id":0,"curl_version":"libcurl/8.8.0 Schannel zlib/1.3.1 brotli/1.1.0 zstd/1.5.6 libidn2/2.3.7 libpsl/0.21.5 libssh2/1.11.0"}

And it's failing with A libcurl function was given a bad argument

This looks to be rooted in this issue in libcurl, as I'm also on curl 8.8.0, and I'm assuming github is as well from the other issues citing the linked issue.

https://github.com/curl/curl/issues/13845

Unfortunately 8.8.0 is the latest release of curl so there's not an easy workaround, and I expect you will be getting similar issues soon.

I've worked around this in our CI with this snippet:

curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sed "s/-w '%{http_code}'//g" | sed 's/\[ "\$code" != "200" \]/[ "$?" != "0" ]/g' | sh -s -- -b $(go env GOPATH)/bin v1.59.1

The http_download_curl function in the install script should probably be updated to work around this bug by only checking the exit code when curl's version is 8.8.0.

Version of golangci-lint

N/A

Configuration

N/A

Go environment

```console $ go version && go env go version go1.22.2 windows/amd64 set GO111MODULE= set GOARCH=amd64 set GOBIN= set GOCACHE=C:\Users\mahuangh\AppData\Local\go-build set GOENV=C:\Users\mahuangh\AppData\Roaming\go\env set GOEXE=.exe set GOEXPERIMENT= set GOFLAGS= set GOHOSTARCH=amd64 set GOHOSTOS=windows set GOINSECURE= set GOMODCACHE=C:\Users\mahuangh\go\pkg\mod set GONOPROXY= set GONOSUMDB= set GOOS=windows set GOPATH=C:\Users\mahuangh\go set GOPRIVATE= set GOPROXY=https://proxy.golang.org,direct set GOROOT=C:\Program Files\Go set GOSUMDB=sum.golang.org set GOTMPDIR= set GOTOOLCHAIN=auto set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64 set GOVCS= set GOVERSION=go1.22.2 set GCCGO=gccgo set GOAMD64=v1 set AR=ar set CC=gcc set CXX=g++ set CGO_ENABLED=1 set GOMOD=NUL set GOWORK= set CGO_CFLAGS=-O2 -g set CGO_CPPFLAGS= set CGO_CXXFLAGS=-O2 -g set CGO_FFLAGS=-O2 -g set CGO_LDFLAGS=-O2 -g set PKG_CONFIG=pkg-config set GOGCCFLAGS=-m64 -mthreads -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\mahuangh\AppData\Local\Temp\go-build4117220378=/tmp/go-build -gno-record-gcc-switches ```

Verbose output of running

N/A

A minimal reproducible example or link to a public repository

$ bash -c 'curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/d681d93d0ff9e4f55b14ec66937b98b8a0918287/install.sh | sh -s -- -b $(go env GOPATH)/bin latest'
golangci/golangci-lint info checking GitHub for tag 'latest'
golangci/golangci-lint crit unable to find 'latest' - use 'latest' or see https://github.com/golangci/golangci-lint/releases for details

Validation

Supporter

boring-cyborg[bot] commented 2 weeks ago

Hey, thank you for opening your first Issue ! 🙂 If you would like to contribute we have a guide for contributors.

ldez commented 2 weeks ago

Hello,

the problem seems related to curl and a fix has been merged https://github.com/curl/curl/commit/eacec9a35047bc71e83bba12403b990327bc8f8f (https://github.com/curl/curl/pull/13857)