selenium: [🐛 Bug]: Selenium Manager binary not executing on Apple Sillicon

What happened?

When SeleniumManager tries to download Firefox driver for MacOS, it is downloading wrong version. I’m getting " Bad CPU type in executable" error (same error message from this issue https://github.com/mozilla/geckodriver/issues/1984).

On release page has two versions https://github.com/mozilla/geckodriver/releases

  • geckodriver-v0.33.0-macos-aarch64.tar.gz
  • geckodriver-v0.33.0-macos.tar.gz

For Apple Silicon machines, it should download aarch64 version.

Last year I solved this problem on webdrivers gem on this PR: https://github.com/titusfortner/webdrivers/pull/234 Basically: System.apple_m1_architecture? ? 'macos-aarch64.tar.gz' : 'macos.tar.gz'

The apple_m1_architecture? method (I would recommend to change method name to apple_silicon?:

def apple_m1_architecture?
  if platform == 'mac' && RUBY_PLATFORM.include?('arm64-darwin')
    Webdrivers.logger.debug 'Apple architecture: M1 (arm64-darwin)'
    return true
  end

  Webdrivers.logger.debug 'Apple architecture: Intel (mac64)'
  false
end

How can we reproduce the issue?

I'm not sure, I'm using capybara on a Rails project, and just removed `webdrivers` gem to use SeleniumManager automatically.

Relevant log output

Selenium::WebDriver::Error::NoSuchDriverError:
            Unable to obtain geckodriver using Selenium Manager; Unsuccessful command executed: ["/Users/stephann/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/selenium-webdriver-4.10.0/bin/macos/selenium-manager", "--browser", "firefox", "--output", "json"]; Bad CPU type in executable - /Users/stephann/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/selenium-webdriver-4.10.0/bin/macos/selenium-manager; For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors/driver_location

# ./spec/system/checkout/add_items_to_cart_spec.rb:42:in `block (3 levels) in <top (required)>'
          # ------------------
          # --- Caused by: ---
          # Errno::EBADARCH:
          #   Bad CPU type in executable - /Users/stephann/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/selenium-webdriver-4.10.0/bin/macos/selenium-manager
          #   ./spec/system/checkout/add_items_to_cart_spec.rb:42:in `block (3 levels) in <top (required)>'


### Operating System

MacOS Monterey 12.6.7 (21G651)

### Selenium version

selenium-webdriver-4.10.0

### What are the browser(s) and version(s) where you see this issue?

Firefox 115.0.2 (64-bit)

### What are the browser driver(s) and version(s) where you see this issue?

geckodriver

### Are you using Selenium Grid?

I'm not sure, I don't think so

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 24 (12 by maintainers)

Most upvoted comments

Looks like Simon figured out how to make it a universal binary using our build system and existing tooling, so we’ll probably end up doing that after all.

  1. Yes, if we could have a universal app we’d love to have it
  2. Based on Mozilla numbers, Apple silicon is 5% of geckodriver downloads. If the choice is having that 5% depend on Rosetta (which is likely installed for other reasons), I’d prefer that to the 95% having to download an extra binary they don’t need.

Yes, Selenium Manager is built with Rust, not Swift. Since the binaries for all supported architectures must be included in each release (and checked into the repo), we are balancing the number of architecture-specific binaries and the total size of the packages / repo. For instance, the windows 32 bit binary is also used for both 32 & 64 bit architectures.

Please install Rosetta and seeing if that allows the binary to work for you. Perhaps everyone else already has it installed so it wasn’t obvious that we needed to be explicit about it as a requirement.

This worked for me. To save some googling for other folks, I installed Rosetta with softwareupdate --install-rosetta

Yes, Selenium Manager is built with Rust, not Swift. Since the binaries for all supported architectures must be included in each release (and checked into the repo), we are balancing the number of architecture-specific binaries and the total size of the packages / repo. For instance, the windows 32 bit binary is also used for both 32 & 64 bit architectures.

Please install Rosetta and seeing if that allows the binary to work for you. Perhaps everyone else already has it installed so it wasn’t obvious that we needed to be explicit about it as a requirement.

Yeah @titusfortner , at first I think it was related with geckodriver, but after downloading selenium manager from repo I could not run selenium-manager.