aspnetcore icon indicating copy to clipboard operation
aspnetcore copied to clipboard

Build fails on Mac M1 with "ENOENT: no such file or directory" due to selenium-standalone

Open mmacy opened this issue 2 years ago • 1 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Describe the bug

Building /src/Components via /src/Components $ ./build.sh fails on a Mac M1 in selenium-standalone due to a recent-ish change to the ARM64-based chromedriver archive's filename convention on the Chromium distribution site.

The first clue was a download failure at some point (possibly during dependency restore when I first opened the project) on https://chromedriver.storage.googleapis.com/108.0.5359.71/chromedriver_mac64_m1.zip, which I cannot for the life of me find in my build logs.

However, this error now repros reliably on every /src/Components $ ./build.sh execution because the script tries to chmod a nonexistent chromedriver archive:

  -----
  selenium-standalone installation finished
  -----
/Users/mmacy/repos/aspnetcore/src/Shared/E2ETesting/E2ETesting.targets(23,5): error : in "chmod".  [/Users/mmacy/repos/aspnetcore/src/Components/test/E2ETest/Microsoft.AspNetCore.Components.E2ETests.csproj]
  See more details below:
  ENOENT: no such file or directory, chmod '/Users/mmacy/repos/aspnetcore/src/Components/test/E2ETest/node_modules/selenium-standalone/.selenium/chromedriver/108.0.5359.71-arm64/chromedriver'
  node:internal/process/promises:289
              triggerUncaughtException(err, true /* fromPromise */);
              ^
  
  [Error: ENOENT: no such file or directory, chmod '/Users/mmacy/repos/aspnetcore/src/Components/test/E2ETest/node_modules/selenium-standalone/.selenium/chromedriver/108.0.5359.71-arm64/chromedriver'] {
    errno: -2,
    code: 'ENOENT',
    syscall: 'chmod',
    path: '/Users/mmacy/repos/aspnetcore/src/Components/test/E2ETest/node_modules/selenium-standalone/.selenium/chromedriver/108.0.5359.71-arm64/chromedriver'
  }
  
  Node.js v19.3.0
  info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
/Users/mmacy/repos/aspnetcore/src/Shared/E2ETesting/E2ETesting.targets(23,5): error : Command failed with exit code 1. [/Users/mmacy/repos/aspnetcore/src/Components/test/E2ETest/Microsoft.AspNetCore.Components.E2ETests.csproj]

Expected Behavior

Executing /src/Components $ ./build.sh should download all the project's dependencies including those dependencies' dependencies, and complete successfully.

Steps To Reproduce

  1. On a Mac M1 machine, follow the steps in BuildFromSource.md to prepare your local build environment.
  2. Execute the /src/Components/build.sh script.

Exceptions (if any)

No response

.NET Version

8.0.100-alpha.1.22531.1

Anything else?

As of version 106.0.5249.61, the filename suffix for the ARM64-based chromedriver ZIP archive changed. The change causes the version of selenium-standalone used by the current build config to fail to download the archive.

The compute-download-urls.js file in the version of selenium-standalone used by the current aspnetcore build/test toolchain does not accommodate the new chromedriver filename convention:

// Busted version - from selenium-standalone in current build/test toolchain
platform = 'mac64' + (process.arch === 'arm64' ? '_m1' : '');

The upstream selenium-standalone repo includes a fix for this in the current compute-download-urls.js:

// Fixed in upstream selenium-standalone repo
platform = parseInt(major, 10) > 105 ? 'mac_arm64' : 'mac64_m1';

Happy to provide more information if you need it, just say the word. 🙂

ℹ️ To get unblocked, M1 Mac users can manually download and extract the right chromedriver to the expected location.

mmacy avatar Jan 02 '23 19:01 mmacy

Thanks for contacting us.

We're moving this issue to the .NET 8 Planning milestone for future evaluation / consideration. We would like to keep this around to collect more feedback, which can help us with prioritizing this work. We will re-evaluate this issue, during our next planning meeting(s). If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues. To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

ghost avatar Jan 05 '23 17:01 ghost

Just hit this today too. This makes it impossible to do aspnetcore development and E2E testing on an arm64 Mac with non-ancient versions of chrome.

Is there any reason not to bump the selenium version to something more recent. 7.1.0 is over 2 years old

https://github.com/dotnet/aspnetcore/blob/e9505bc64e21ce4308b6c1f63640a4d6f82d5d9d/src/Components/test/E2ETest/package.json#L16

and

https://github.com/dotnet/aspnetcore/blob/e9505bc64e21ce4308b6c1f63640a4d6f82d5d9d/src/Shared/E2ETesting/E2ETesting.targets#L54

lambdageek avatar May 17 '23 17:05 lambdageek

Turns out it's quite challenging to bump the selenium-standalone version (I gave it a try in #48288, but I think I will need to give up on that PR unless I have a big chunk of free time).

Things that the PR uncovered:

  1. there are two places where selenium-standalone is mentioned in package.json/jarn.lock: in src/ProjectTemplates/test/Templates.Tests and in src/Components/test/E2ETest

  2. Selenium changed the URL that they serve instead of /wd/hub you just go to / now. Also you use --host and --port instead of -host and -port See https://github.com/dotnet/aspnetcore/pull/48288/commits/e137230b35814121e268c3bdbb6ffa113333df2d#diff-220c96679ae5c8b66a7c08d0514422c79c41bbf522874580097ce4dd6b6d8f1e

  3. newer versions of selenium-standalone have a bug in how they parse --javaArgs (thanks @MackinnonBuck - https://github.com/webdriverio/selenium-standalone/issues/736).

    A workaround is to instead use the JDK_JAVA_OPTIONS environment variable to go behind selenium-standalones back to pass the arguments. See https://github.com/dotnet/aspnetcore/pull/48288/commits/bb2505e80a5d978cca7b452e25f164cb4cf108bd

  4. There is some kind of a version mismatch warning that gets generated when the system-wide chromedriver is run agains the systemwide chrome on AzDO:

    Starting ChromeDriver 112.0.5615.49 (bd2a7bcb881c11e8cfe3078709382934e3916914-refs/branch-heads/5615@{#936}) on port 58512
    [xUnit.net 00:00:18.06] Microsoft.AspNetCore.Components.E2ETests: Only local connections are allowed.
    [xUnit.net 00:00:18.06] Microsoft.AspNetCore.Components.E2ETests: Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
    [xUnit.net 00:00:18.06] Microsoft.AspNetCore.Components.E2ETests: ChromeDriver was started successfully.
    [xUnit.net 00:00:19.48] Microsoft.AspNetCore.Components.E2ETests: [1684379260.728][WARNING]: This version of ChromeDriver has not been tested with Chrome version 113.
    [xUnit.net 00:00:19.59] Microsoft.AspNetCore.Components.E2ETests: 03:07:40.839 INFO [ProtocolHandshake.createSession] - Detected upstream dialect: W3C
    [xUnit.net 00:00:19.61] Microsoft.AspNetCore.Components.E2ETests: 03:07:40.855 INFO [LocalNode.newSession] - Session created by the Node. Id: 82dc2f99fc0f1e7bec9019e24e8833ea, Caps: Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 113.0.5672.63, chrome: {chromedriverVersion: 112.0.5615.49 (bd2a7bcb881c..., userDataDir: /tmp/BrowserFixtureUserProf...}, goog:chromeOptions: {debuggerAddress: localhost:40513}, networkConnectionEnabled: false, pageLoadStrategy: normal, platformName: LINUX, proxy: Proxy(), se:cdp: http://localhost:40513,/ se:cdpVersion: 113.0.5672.63, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true, webauthn:extension:minPinLength: true, webauthn:extension:prf: true, webauthn:virtualAuthenticators: true}
    [xUnit.net 00:00:19.63] Microsoft.AspNetCore.Components.E2ETests: 03:07:40.871 INFO [LocalDistributor.newSession] - Session created by the Distributor. Id: 82dc2f99fc0f1e7bec9019e24e8833ea 
    [xUnit.net 00:00:19.63] Microsoft.AspNetCore.Components.E2ETests:  Caps: Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 113.0.5672.63, chrome: {chromedriverVersion: 112.0.5615.49 (bd2a7bcb881c..., userDataDir: /tmp/BrowserFixtureUserProf...}, goog:chromeOptions: {debuggerAddress: localhost:40513}, goog:loggingPrefs: {browser: ALL, driver: ALL}, networkConnectionEnabled: false, pageLoadStrategy: normal, platformName: LINUX, proxy: Proxy(), se:cdp: ws://127.0.0.1:44379/sessio..., se:cdpVersion: 113.0.5672.63, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true, webauthn:extension:minPinLength: true, webauthn:extension:prf: true, webauthn:virtualAuthenticators: true}
    

    This might be unrelated - it probably exists on main too - just we don't notice it because noone looks at the passing logs and it's just a warning

  5. With the new selenium, sometimes chrome seems to crash and selenium is unable to start it again (I think - the logs are huge it's hard to tell)

    [xUnit.net 00:23:18.12] Microsoft.AspNetCore.Components.E2ETests: 03:30:39.365 WARN [DriverServiceSessionFactory.apply] - Error while creating session with the driver service. Stopping driver service: Could not start a new session. Response code 500. Message: unknown error: Chrome failed to start: exited abnormally.
    [xUnit.net 00:23:18.12] Microsoft.AspNetCore.Components.E2ETests:   (unknown error: DevToolsActivePort file doesn't exist)
    [xUnit.net 00:23:18.12] Microsoft.AspNetCore.Components.E2ETests:   (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
    [xUnit.net 00:23:18.12] Microsoft.AspNetCore.Components.E2ETests: Build info: version: '4.4.0', revision: 'e5c75ed026a'
    [xUnit.net 00:23:18.12] Microsoft.AspNetCore.Components.E2ETests: System info: host: 'fv-az232-119', ip: '10.1.0.24', os.name: 'Linux', os.arch: 'amd64', os.version: '5.15.0-1037-azure', java.version: '11.0.19'
    [xUnit.net 00:23:18.12] Microsoft.AspNetCore.Components.E2ETests: Driver info: driver.version: unknown
    

Unclear what the next step is here...

If anyone is interested in pickup up where I left off, this is all the info I have so far.

For what it's worth the code in the PR works for me locally on macOS arm64 and linux x64 (which already worked - but it doesn't break it, at least). but it would be nice not to carry around patches just to do local development.

lambdageek avatar May 18 '23 16:05 lambdageek

Thanks for contacting us.

We're moving this issue to the .NET 9 Planning milestone for future evaluation / consideration. We would like to keep this around to collect more feedback, which can help us with prioritizing this work. We will re-evaluate this issue, during our next planning meeting(s). If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues. To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

ghost avatar Oct 04 '23 17:10 ghost

Is there still something to do here? I think @javiercn already bumped the version of chromedriver that gets used.

lambdageek avatar Oct 04 '23 19:10 lambdageek

Closing this out. If we run into this problem again, we can open a new issue.

MackinnonBuck avatar Dec 04 '23 23:12 MackinnonBuck