From 79fd8711738a0703797b6794fba7df613d757fb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20L=C3=B8vdal?= Date: Sun, 23 Jan 2022 19:48:56 +0100 Subject: [PATCH] Fix open-uri call Without this fix downloading will fail like: Host OS... linux Attempting to download Arduino 0.13.0 package with open-uribundler: failed to load command: arduino_ci.rb (/.../vendor/bundle/ruby/3.0.0/bin/arduino_ci.rb) /.../arduino_ci/lib/arduino_ci/arduino_downloader.rb:111:in `initialize': No such file or directory @ rb_sysopen - https://github.com/arduino/arduino-cli/releases/download/0.13.0/arduino-cli_0.13.0_Linux_64bit.tar.gz (Errno::ENOENT) and when running through trace the log gives: access("/usr/bin/tar", X_OK) = 0 newfstatat(AT_FDCWD, "/usr/bin/tar", {st_mode=S_IFREG|0755, st_size=527464, ...}, 0) = 0 newfstatat(AT_FDCWD, "arduino-cli_0.13.0_Linux_64bit.tar.gz", 0x7fff95f8caa0, 0) = -1 ENOENT (No such file or directory) write(1, "Attempting to download Arduino 0.13.0 package with open-uri", 59) = 59 openat(AT_FDCWD, "https://github.com/arduino/arduino-cli/releases/download/0.13.0/arduino-cli_0.13.0_Linux_64bit.tar.gz", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) ioctl(2, TCGETS, {B38400 opost isig icanon echo ...}) = 0 ioctl(1, TCGETS, {B38400 opost isig icanon echo ...}) = 0 so obviously the bare open call is mapped to a filesystem open call. The gem 'open-uri' is referenced earlier in the file and is obviously the intended target. https://github.com/ruby/open-uri documents the API to be URI.open, and substituting with that made downloading work. --- lib/arduino_ci/arduino_downloader.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/arduino_ci/arduino_downloader.rb b/lib/arduino_ci/arduino_downloader.rb index 6b4eb24b..0e8fdbdb 100644 --- a/lib/arduino_ci/arduino_downloader.rb +++ b/lib/arduino_ci/arduino_downloader.rb @@ -108,7 +108,7 @@ def download dots = needed_dots end - open(package_url, ssl_verify_mode: 0, progress_proc: dot_printer) do |url| + URI.open(package_url, ssl_verify_mode: 0, progress_proc: dot_printer) do |url| File.open(package_file, 'wb') { |file| file.write(url.read) } end rescue Net::OpenTimeout, Net::ReadTimeout, OpenURI::HTTPError, URI::InvalidURIError => e