19

Suddenly on the afternoon of January 6, 2021, my Selenium Protractor tests under OSX stopped working with the mysterious error

spawn Unknown system error -86

I did some research and discovered that error number 86 is the same as

Bad CPU type in executable

and ran the following to compare the cpu architecture of my chromedriver binary to my system:

% file chromedriver_87.0.4280.88
chromedriver_87.0.4280.88: Mach-O 64-bit executable arm64
% uname -a
Darwin kobl179273m 19.6.0 Darwin Kernel Version 19.6.0: Thu Oct 29 22:56:45 PDT 2020; root:xnu-6153.141.2.2~1/RELEASE_X86_64 x86_64
% uname -p
i386

How can I fix the chromedriver binary used by my Selenium so that it will run on my Intel x64 mac and clear the "system error -86" or "Bad CPU type" message?

emery
  • 8,603
  • 10
  • 44
  • 51
  • 1
    It appears that chromedriver now supports Apple Silicon ARM architecture and "webdriver-manager update --versions.chrome=" is now always grabbing the arm64 build of chromedriver from https://chromedriver.storage.googleapis.com/ instead of the x86_64 build. I'm trying to figure out how to force webdriver-manager to download the intel x86 build instead. – emery Jan 07 '21 at 20:19
  • The problem is that till chrome version 86 there was only one version for mac64 chromedriver. But since chrome version 87. There are two binaries for chrome mac64 and mac64_ml. Only mac64_ml is downloaded which is for arm64 arch So the the fix needs to be done in webdriver_manager chrome_xml.js. – Deepak Srinivasan Jan 08 '21 at 09:50
  • 1
    There is an open issue. https://github.com/angular/webdriver-manager/issues/476 – Deepak Srinivasan Jan 08 '21 at 09:55
  • 2
    Incidentally, it is a total coincidence that error code 86 can be fixed by rolling back to Chrome 86 – emery Jan 08 '21 at 17:23

5 Answers5

17

The issue is described in https://github.com/angular/webdriver-manager/issues/476. This has been now fixed in 12.1.8 so just update to that webdriver manager.

For most users this can be accomplished with

npm uninstall protractor && npm install protractor
emery
  • 8,603
  • 10
  • 44
  • 51
  • 3
    I ran a fresh `npm install` with the latest version of Protractor and that fixed it. Thanks. – Steve Brush Jan 11 '21 at 17:54
  • I am marking this as the preferred answer, since although the information in my other answer may be useful to anyone who gets unkonwn system error -86 in the future, for most people who are seeing the error due to the _m1 Silicon Arm release of Chromedriver, the easiest solution will be to go ahead and upgrade to the newer version of protractor and webdriver-manager which fixes it. – emery Jan 14 '21 at 17:22
  • 2
    This might be common sense for some, but I had to go into usr/local/lib/node_modules` of my mac and delete the `webdriver-manager` directory before running `npm install`. After I did, things worked. Incidentally, the re-install ended up in the bin of my recently installed .nvm directory, found by running `which webdriver-manager`. – mac Jan 17 '21 at 04:21
11

Edit: this answer should be considered deprecated now that the underlying bug in webdriver-manager has been fixed. A better solution would be to upgrade to the newest version of webdriver-manager. The answer below may be useful if people need to use an older version of webdriver-manager which still has the bug.

As per Deepak Srinivasan's comment above, this error is caused by https://github.com/angular/webdriver-manager/issues/476

Root Cause: The ChromeDriver team added "_m1" to the end of the filename for their Apple Silicon ARM builds of Chromedriver -- but both the Silicon and Intel versions of chromedriver have "mac64" in the filename, and the version number is exactly the same. This causes webdriver-manager to always download the Silicon build of Chromedriver, even on Intel macs. As a general solution, simply avoid using the chromedriver that has _m1 in its filename if you are on an Intel mac.

Solution 1: Downgrade to Chrome 86.0.4240.198 and Chromedriver 86.0.4240.22. These versions work together and are the most recent versions prior to the new and problematic support for Silicon ARM

Chrome 86 download page: https://google-chrome.en.uptodown.com/mac/download/2920124

Disable auto-updates in Chrome: https://superuser.com/questions/1359017/how-do-i-disable-automatic-updates-of-google-chrome-on-mac-os-x

Chromedriver 86: https://chromedriver.storage.googleapis.com/index.html?path=86.0.4240.22/

% webdriver-manager update --versions.chrome=86.0.4240.22

Solution 2: Modify the webdriver-manager npm package to point to the correct chromedriver (thanks to ciekaway from the angular github issue page for this fix)

Modify the following file

node_modules/webdriver-manager/built/lib/files/file_manager.js

or, if using protractor

node_modules/protractor/node_modules/webdriver-manager/built/lib/files/file_manager.js

Near the top of the downloadFile method around line 166, add the following line to remove "_m1" from the name of the file:

fileUrl.url = fileUrl.url.replace(/_m1/, '');

It needs to be after the beginning of the .then block that starts with

binary.getUrl(binary.version()).then(fileUrl => {

it also needs to be before the next reference to fileUrl.
For example:

binary.getUrl(binary.version()).then(fileUrl => {
    binary.versionCustom = fileUrl.version;
    fileUrl.url = fileUrl.url.replace(/_m1/, '');
    let filePath = path.resolve(outputDir, binary.filename());

Note that this solution is temporary. It will be overwritten by an npm install. The Chromedriver and/or the webdriver-manager team will probably fix this issue, at which point you should clear the modified version of your webdriver-manager and download the fix from npm.

emery
  • 8,603
  • 10
  • 44
  • 51
  • Tried to do it with solution 1, but later got error trying to run protractor test. Error: E/launcher - SessionNotCreatedError: Unable to create new service: ChromeDriverService. Driver info: driver.version: unknown – user1328889 Jan 13 '21 at 12:23
  • 1
    Turned out I had to specify version, like this: webdriver-manager start --versions.chrome 86.0.4240.22 – user1328889 Jan 13 '21 at 12:41
  • I tried solution 1 but I get same error as @user1328889. I used ./node_modules/.bin/webdriver-manager start --versions.chrome=86.0.4240.198 but that gave me this error: E/start - Selenium Standalone is not present. Install with webdriver-manager update --standalone. I do see selenium-server-standalone-3.141.59.jar in my selenium folder though. – Skyler Firestone Jan 22 '21 at 23:17
  • Another issue with solution #1 is that chrome keeps autoupdating to version 88 even after disabling the updates. It shows 86 in the about chrome settings but when you right click on the app info you can see that the version is 88. Due to this tests fail with this error: essionNotCreatedError: session not created: This version of ChromeDriver only supports Chrome version 86 Current browser version is 88.0.4324.96 with binary path /Applications/Google Chrome.app/Contents/MacOS/Google Chrome – Skyler Firestone Jan 23 '21 at 00:32
  • @SkylerFirestone, you can try webdriver-manager update --standalone --versions.chrome=86.0.4240.198. Also, to prevent Chrome updates, try sudo chmod -R 000 ~/Library/Google as per the link in the answer. But in general, you shouldn't need either solution 1 or 2 any longer if you update to the newest chrome and just use webdriver-manager update or webdriver manager update --standalone then you should get the newer version of webdriver manager which has a patch that fixes the issue, as per the other accepted answer which isn't mine. Good luck and let us know how it goes. – emery Jan 26 '21 at 05:21
  • 1
    Thanks @emery. I tried npm uninstall protractor && npm install protractor and now it works. – Skyler Firestone Jan 29 '21 at 00:25
6

For macOS Catalina Version 10.15.6 (19G73)

In my case I was working with Rails and Capybara for feature tests. What worked for me was

  1. First, find the actual chromedriver location running:

    which chromedriver
    
    # Which returned:
    
    /Users/alex/.webdrivers/chromedriver
    
  2. Then, install chromedriver via Homebrew:

    brew install chromedriver
    
  3. Then, remove old chromedriver reference found at previous location with:

    rm /Users/alex/.webdrivers/chromedriver
    
  4. Now, link the old chromedriver reference to the one installed with brew:

    ln -s /usr/local/bin/chromedriver /Users/alex/.webdrivers/chromedriver
    
  5. Then, open Finder app, then click on Go menu and then click Go to folder ... option, and enter this route:

    /usr/local/Caskroom/chromedriver/
    
  6. There you should see a folder with the chromedriver version you have installed, something like this:

    88.0.4324.96
    
  7. Enter that folder and you should see the chromedriver binary file.

  8. Right click on it, and click on Open

    Now, you should get a terminal window popping up with the output:

    Last login: Sun Jan 31 12:29:15 on ttys001
    /usr/local/Caskroom/chromedriver/88.0.4324.96/chromedriver ; exit;
       ~  /usr/local/Caskroom/chromedriver/88.0.4324.96/chromedriver ; exit;
    Starting ChromeDriver 88.0.4324.96 (68dba2d8a0b149a1d3afac56fa74648032bcf46b-    refs/branch-heads/4324@{#1784}) on port 9515
    Only local connections are allowed.
    Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
    ChromeDriver was started successfully.
    
  9. Finally, press Ctrl+C to stop the execution and quit the terminal window.

Now, you should be able to run capybara tests.

alexventuraio
  • 8,126
  • 2
  • 30
  • 35
  • This is a specific set of instructions for updating Chromedriver in a Rails/Capybara framework that could be a more generic response to the question "How do I update Chromedriver in a Rails/Capybara framework". Thanks for the contribution. – emery Feb 03 '21 at 18:15
3
npm uninstall protractor && npm install protractor
0

If you use webdrivers gem, upgrade it:

bundle update webdrivers
DonPaulie
  • 2,004
  • 17
  • 26