New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Download chromedriver binary for Mac M1 #327
Conversation
A link for reference: https://developer.apple.com/documentation/apple-silicon/about-the-rosetta-translation-environment#3616845 Basically, |
} | ||
|
||
function isEmulatedRosettaEnvironment() { | ||
const archName = child_process.spawnSync('uname', ['-m']).stdout.toString().trim(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure you need this. Can't we just check for process.arch === 'x64'
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @giggio! In my tests, if I'm running Node.js under Rosetta 2, process.arch
will return x86_64
and will return arm64
if running natively on Apple Silicon.
So the only way I've found to get the real architecture of the processor is by running uname -m
and then sysctl -in sysctl.proc_translated
.
Let me know if it's not clear 😃
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I understand. So, what if we make the function like this:
function isEmulatedRosettaEnvironment() {
const processTranslated = child_process.spawnSync('sysctl', ['-in', 'sysctl.proc_translated'])
.stdout.toString()
.trim();
return processTranslated === '1';
}
And then call it only from:
if (process.arch === 'x64') {
if (isEmulatedRosettaEnvironment())
return 'mac64_m1';
return 'mac64';
}
Would that work? If yes, we have one less process spawning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @giggio!
So sysctl -in sysctl.proc_translated
returns an empty string on an Intel Mac, so I guess you're right, we don't need to check for uname
here. I'll change it. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @johnathafelix! When do you expect to update this? I'd like to ask a friend to verify it after um change it.
@johnathafelix It looks good. I don't have an M1 Mac to test, so I need somebody else to validate. |
Thanks @giggio! Let's wait until someone else with a M1 Mac validates this. |
Great, I merged it! Thanks for everyone that helped testing it! |
@samuelramox this branch was a little behind, the latest on |
Published as |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
I noticed that using Node.js emulated with Rosetta made the script download the Intel version of the chromedriver instead of the Apple Silicon one.
I've changed it the platform check so it can see what's the real processor architecture and download the chromedriver accordingly.
I run browsers without emulation but not Node.js since some packages are still not compatible.
We are in need of someone to test this
You need to be on an M1 Mac, this is how you do it:
Clone this PR:
git clone https://github.com/johnathafelix/node-chromedriver.git cd node-chromedriver npm install
Then, check if you can run Chromedriver:
If it shows output correctly, then it worked. This is the expected output (somewhat similar is ok):
If it works, please comment bellow.