From a3e01fd8debdcdc5e8ebca0756c054452104fe75 Mon Sep 17 00:00:00 2001 From: Vivian Vijay Ludrick <116781909+vivianludrick@users.noreply.github.com> Date: Tue, 18 Aug 2026 11:51:47 +0530 Subject: [PATCH 1/2] LOC-7291: download darwin-arm64 binary on Apple Silicon On macOS the binding now selects BrowserStackLocal-darwin-arm64 when the runtime reports arm64/aarch64; x64 runtimes (including x64-under-Rosetta) keep BrowserStackLocal-darwin-x64, preserving current behavior. Co-Authored-By: Claude Fable 5 --- lib/BrowserStack/Local.pm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/BrowserStack/Local.pm b/lib/BrowserStack/Local.pm index 0e5d837..67f4541 100644 --- a/lib/BrowserStack/Local.pm +++ b/lib/BrowserStack/Local.pm @@ -8,6 +8,7 @@ use IO::Socket; use LWP::Simple; use File::Temp; use Config; +use POSIX (); use Cwd; use File::Temp qw(tempdir); use File::Path qw(make_path); @@ -200,6 +201,9 @@ sub get_available_path { sub platform_url { if ($^O =~ "darwin") { + if ((POSIX::uname())[4] =~ /arm64|aarch64/) { + return "http://s3.amazonaws.com/browserStack/browserstack-local/BrowserStackLocal-darwin-arm64"; + } return "http://s3.amazonaws.com/browserStack/browserstack-local/BrowserStackLocal-darwin-x64"; } elsif ($^O =~ /^Win/) { From ed5218fe07ad73f5f50158fab80f4e2909ae3f65 Mon Sep 17 00:00:00 2001 From: Vivian Vijay Ludrick <116781909+vivianludrick@users.noreply.github.com> Date: Thu, 20 Aug 2026 15:56:52 +0530 Subject: [PATCH 2/2] review: check download status, fall back to x64 when arm64 fetch fails MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Per review on PR #15: this binding hardcodes the legacy S3 host, where the arm64 object may not exist yet — and getstore's status was ignored, so an HTTP error body would be saved as the binary and satisfy the -x check forever. Now: getstore status is checked; a failed -darwin-arm64 download falls back to the x64 binary (works on Apple Silicon via Rosetta 2); if everything fails, the file is removed and the error is raised instead of left on disk. Verified with a stubbed-getstore harness: arm64 404 -> x64 fallback succeeds; both-fail -> dies, no poisoned file left. Co-Authored-By: Claude Fable 5 --- lib/BrowserStack/Local.pm | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/BrowserStack/Local.pm b/lib/BrowserStack/Local.pm index 67f4541..655b770 100644 --- a/lib/BrowserStack/Local.pm +++ b/lib/BrowserStack/Local.pm @@ -222,7 +222,21 @@ sub platform_url { sub download_binary { my ($self) = @_; my $url = $self->platform_url(); - getstore($url, $self->{binary_path}); + my $status = getstore($url, $self->{binary_path}); + # If the arm64 binary is not published to the legacy bucket yet, fall back + # to the x64 binary, which still works on Apple Silicon via Rosetta 2 — + # releasing must not turn a working download into a 404. + if (!is_success($status) && $url =~ /-darwin-arm64$/) { + $url =~ s/-darwin-arm64$/-darwin-x64/; + $status = getstore($url, $self->{binary_path}); + } + if (!is_success($status)) { + # don't leave the HTTP error body behind as an "installed" binary — it + # would satisfy the -x check in get_binary_path on every later run and + # stick until the user deletes it by hand + unlink $self->{binary_path}; + die "Failed to download BrowserStackLocal binary (HTTP $status) from $url\n"; + } chmod 0777, $self->{binary_path}; }