arduino / arduino-cli

Arduino command line tool
https://arduino.github.io/arduino-cli/latest/
GNU General Public License v3.0
4.29k stars 373 forks source link

Failed to install using bash on Windows #2667

Open lucasssvaz opened 1 month ago

lucasssvaz commented 1 month ago

Describe the problem

Since the latest release I can't install through the script. It originally started happening in our CI and I tested locally to make sure it is also happening.

https://github.com/espressif/arduino-esp32/actions/runs/9957218514/job/27508776142

As seen on the CI, this only happens in Windows.

To reproduce

lucas@Desktop-Win MINGW64 ~
$ curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh
Installing in /c/Users/lucas/bin
ARCH=64bit
OS=Windows
Using curl as download tool
Downloading https://downloads.arduino.cc/arduino-cli/arduino-cli_1.0.2_Windows_64bit.zip
Failed to install arduino-cli

lucas@Desktop-Win MINGW64 ~
$ curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh -s 1.0.1
Installing in /c/Users/lucas/bin
ARCH=64bit
OS=Windows
Using curl as download tool
Downloading https://downloads.arduino.cc/arduino-cli/arduino-cli_1.0.1_Windows_64bit.zip
Failed to install arduino-cli

lucas@Desktop-Win MINGW64 ~
$ curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh -s nightly-latest
Installing in /c/Users/lucas/bin
ARCH=64bit
OS=Windows
Using curl as download tool
Downloading https://downloads.arduino.cc/arduino-cli/nightly/arduino-cli_nightly-latest_Windows_64bit.zip
Failed to install arduino-cli

lucas@Desktop-Win MINGW64 ~
$ curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | BINDIR=. sh
Installing in .
ARCH=64bit
OS=Windows
Using curl as download tool
Downloading https://downloads.arduino.cc/arduino-cli/arduino-cli_1.0.2_Windows_64bit.zip
Failed to install arduino-cli

Expected behavior

Normal installation.

Arduino CLI version

1.0.2

Operating system

Windows

Operating system version

Windows 10/windows-latest

Additional context

No response

Issue checklist

P-R-O-C-H-Y commented 1 month ago

@pillo79 Can you please take a look?

pillo79 commented 1 month ago

cc @umbynos

P-R-O-C-H-Y commented 1 month ago

Fail from last run approx 30 mins ago: https://github.com/espressif/arduino-esp32/actions/runs/10077079853/job/27858827252?pr=10070#step:4:18

umbynos commented 1 month ago

Hello, I just tried on a Windows machine with git bash installed and everything seems to work just fine:

$ curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh
Installing in /c/Users/Arduino/bin
ARCH=64bit
OS=Windows
Using curl as download tool
Downloading https://downloads.arduino.cc/arduino-cli/arduino-cli_1.0.3_Windows_64bit.zip
Archive:  /tmp/arduino-cli_1.0.3_Windows_64bit.zip
  inflating: /tmp/arduino-cli/arduino-cli.exe
  inflating: /tmp/arduino-cli/LICENSE.txt
arduino-cli  Version: 1.0.3 Commit: 8b6ad258 Date: 2024-07-23T08:45:25Z installed successfully in /c/Users/Arduino/bin

Additionally, if you are installing the arduino-cli in a workflow I recommend using https://github.com/arduino/setup-arduino-cli

lucasssvaz commented 1 month ago

Just run it again on a fresh install with git bash on Win 10 and same error happens:

lucas@Desktop-Win MINGW64 ~
$ curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh
Installing in /c/Users/lucas/bin
ARCH=64bit
OS=Windows
Using curl as download tool
Downloading https://downloads.arduino.cc/arduino-cli/arduino-cli_1.0.3_Windows_64bit.zip
Failed to install arduino-cli
cmaglie commented 1 month ago

Could you run with curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | bash -x so we have a bit more logs?

lucasssvaz commented 1 month ago
lucas@Desktop-Win MINGW64 ~
$ curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | bash -x
+ PROJECT_OWNER=arduino
+ PROJECT_NAME=arduino-cli
+ EFFECTIVE_BINDIR=
+ DEFAULT_BINDIR=/c/Users/lucas/bin
+ trap bye EXIT
+ initDestination
+ '[' -n '' ']'
+ '[' '!' -d /c/Users/lucas/bin ']'
+ EFFECTIVE_BINDIR=/c/Users/lucas/bin
+ echo 'Installing in /c/Users/lucas/bin'
Installing in /c/Users/lucas/bin
+ set -e
+ initArch
++ uname -m
+ ARCH=x86_64
+ case $ARCH in
+ ARCH=64bit
+ echo ARCH=64bit
ARCH=64bit
+ initOS
++ uname -s
+ OS=MINGW64_NT-10.0-19045
+ case "$OS" in
+ OS=Windows
+ echo OS=Windows
OS=Windows
+ initFallbackArch
+ case "${OS}_${ARCH}" in
+ initDownloadTool
+ command -v curl
+ DOWNLOAD_TOOL=curl
+ echo 'Using curl as download tool'
Using curl as download tool
+ downloadFile ''
+ '[' -z '' ']'
+ checkLatestVersion
+ CHECKLATESTVERSION_REGEX='v\?[0-9][A-Za-z0-9\.-]*'
+ CHECKLATESTVERSION_LATEST_URL=https://github.com/arduino/arduino-cli/releases/latest
+ '[' curl = curl ']'
++ curl -SsL https://github.com/arduino/arduino-cli/releases/latest
++ grep -o '<title>Release v\?[0-9][A-Za-z0-9\.-]* · arduino/arduino-cli'
++ grep -o 'v\?[0-9][A-Za-z0-9\.-]*'
+ CHECKLATESTVERSION_TAG=v1.0.3
+ '[' v1.0.3 = '' ']'
+ TAG=v1.0.3
+ APPLICATION_DIST_PREFIX=arduino-cli_1.0.3_
+ '[' Windows = Windows ']'
+ APPLICATION_DIST_EXTENSION=.zip
+ APPLICATION_DIST=arduino-cli_1.0.3_Windows_64bit.zip
+ case "$TAG" in
+ DOWNLOAD_URL_PREFIX=https://downloads.arduino.cc/arduino-cli/
+ DOWNLOAD_URL=https://downloads.arduino.cc/arduino-cli/arduino-cli_1.0.3_Windows_64bit.zip
+ INSTALLATION_TMP_FILE=/tmp/arduino-cli_1.0.3_Windows_64bit.zip
+ echo 'Downloading https://downloads.arduino.cc/arduino-cli/arduino-cli_1.0.3_Windows_64bit.zip'
Downloading https://downloads.arduino.cc/arduino-cli/arduino-cli_1.0.3_Windows_64bit.zip
++ getFile https://downloads.arduino.cc/arduino-cli/arduino-cli_1.0.3_Windows_64bit.zip /tmp/arduino-cli_1.0.3_Windows_64bit.zip
++ GETFILE_URL=https://downloads.arduino.cc/arduino-cli/arduino-cli_1.0.3_Windows_64bit.zip
++ GETFILE_FILE_PATH=/tmp/arduino-cli_1.0.3_Windows_64bit.zip
++ '[' curl = curl ']'
+++ curl -s -w '%{http_code}' -L https://downloads.arduino.cc/arduino-cli/arduino-cli_1.0.3_Windows_64bit.zip -o /tmp/arduino-cli_1.0.3_Windows_64bit.zip
++ GETFILE_HTTP_STATUS_CODE=000
++ echo 000
+ httpStatusCode=000
+ '[' 000 -ne 200 ']'
+ '[' -n '' ']'
+ '[' 000 -ne 200 ']'
+ echo 'Did not find a release for your system: Windows 64bit'
Did not find a release for your system: Windows 64bit
+ echo 'Trying to find a release using the GitHub API.'
Trying to find a release using the GitHub API.
+ LATEST_RELEASE_URL=https://api.github.com/repos/arduino/arduino-cli/releases/tags/v1.0.3
+ '[' curl = curl ']'
++ curl -sL --write-out 'HTTPSTATUS:%{http_code}' https://api.github.com/repos/arduino/arduino-cli/releases/tags/v1.0.3
+ HTTP_RESPONSE=HTTPSTATUS:000
+ bye
+ BYE_RESULT=43
+ '[' 43 '!=' 0 ']'
+ echo 'Failed to install arduino-cli'
Failed to install arduino-cli
+ exit 43
cmaglie commented 1 month ago

I tried the same and on my PC I get:

+++ curl -s -w '%{http_code}' -L https://downloads.arduino.cc/arduino-cli/arduino-cli_1.0.3_Windows_64bit.zip -o /tmp/arduino-cli_1.0.3_Windows_64bit.zip
++ GETFILE_HTTP_STATUS_CODE=200
++ echo 200
+ httpStatusCode=200

it seems that your curl returns 000 instead of 200 🤔 could you try:

curl -s -w '%{http_code}' -L https://downloads.arduino.cc/arduino-cli/arduino-cli_1.0.3_Windows_64bit.zip -o /tmp/arduino-cli_1.0.3_Windows_64bit.zip
cmaglie commented 1 month ago

Also a curl --version mine is:

$ curl --version
curl 7.61.1 (x86_64-w64-mingw32) libcurl/7.61.1 OpenSSL/1.0.2p (WinSSL) zlib/1.2.11 libidn2/2.0.5 nghttp2/1.33.0
Release-Date: 2018-09-05
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smtp smtps telnet tftp
Features: AsynchDNS IDN IPv6 Largefile SSPI Kerberos SPNEGO NTLM SSL libz TLS-SRP HTTP2 HTTPS-proxy MultiSSL Metalink
lucasssvaz commented 1 month ago
lucas@Desktop-Win MINGW64 ~
$ curl -s -w '%{http_code}' -L https://downloads.arduino.cc/arduino-cli/arduino-cli_1.0.3_Windows_64bit.zip -o /tmp/arduino-cli_1.0.3_Windows_64bit.zip
000

lucas@Desktop-Win MINGW64 ~
$ curl --version
curl 8.8.0 (x86_64-w64-mingw32) 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
Release-Date: 2024-05-22
Protocols: dict file ftp ftps gopher gophers http https imap imaps ipfs ipns ldap ldaps mqtt pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp
Features: alt-svc AsynchDNS brotli HSTS HTTPS-proxy IDN IPv6 Kerberos Largefile libz NTLM PSL SPNEGO SSL SSPI threadsafe UnixSockets zstd
cmaglie commented 1 month ago

Please, try:

curl -I -L https://downloads.arduino.cc/arduino-cli/arduino-cli_1.0.3_Windows_64bit.zip

(sorry for the long testing I'm a bit lost here... I'm trying to figure out what's happening with your curl)

lucasssvaz commented 1 month ago
$ curl -I -L https://downloads.arduino.cc/arduino-cli/arduino-cli_1.0.3_Windows_64bit.zip
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0 15.2M    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0HTTP/1.1 200 OK
Date: Thu, 25 Jul 2024 19:33:01 GMT
Content-Type: application/zip
Content-Length: 15942283
Connection: keep-alive
CF-Ray: 8a8e94497e5f82e5-GIG
CF-Cache-Status: HIT
Accept-Ranges: bytes
Age: 110287
ETag: "438dd459e3cc8f312ef882d68fe80c7e-2"
Last-Modified: Tue, 23 Jul 2024 08:50:16 GMT
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
Vary: Accept-Encoding
Via: 1.1 50fb19eda678e6a896981a444fb09aa6.cloudfront.net (CloudFront)
x-amz-cf-id: EdXDluf2OaIATJSTfNQyCMWwwUWccwY9vL_N2Z0sHOL3-zfg9r-a9w==
x-amz-cf-pop: MIA3-P3
x-amz-id-2: UuCPkJ05XTtqAYF6C/j1UuPYSF4VkHTdHn0n7Ncf7sXObkC4kqyFPB+H47ZSpvK/cjh8uUw43gWmWkaD7F/uFA==
x-amz-replication-status: COMPLETED
x-amz-request-id: FS133ZNW0HKYM6RF
x-amz-server-side-encryption: AES256
x-amz-version-id: ZCRd.9ppRtjB1b51.DEElxqFRdJLGARl
x-cache: Miss from cloudfront
Server: cloudflare
lucasssvaz commented 1 month ago
lucas@Desktop-Win MINGW64 ~
$ curl -s -w '%{http_code}\n' -fL https://downloads.arduino.cc/arduino-cli/arduino-cli_1.0.3_Windows_64bit.zip ; echo "Exit code: $?"
000
Exit code: 43

From MAN:

43
Internal error. A function was called with a bad parameter.

BTW, If I do:

curl -L https://downloads.arduino.cc/arduino-cli/arduino-cli_1.0.3_Windows_64bit.zip -o arduino-cli.zip

It downloads fine.

cmaglie commented 1 month ago

At this point, I'm wondering if it's better to check both the exit code AND the HTTP status code (that may be 000 that means... "something" happened...). I'm also keen to remove the -s, it will be a bit more verbose in normal conditions but will help to diagnose the problem in case of errors.