Skip to content
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

Support installation on Mac M1 ARM (using rosetta2) #264

Closed
pedropaf opened this issue Feb 11, 2021 · 25 comments
Closed

Support installation on Mac M1 ARM (using rosetta2) #264

pedropaf opened this issue Feb 11, 2021 · 25 comments

Comments

@pedropaf
Copy link

I'm trying to install PACT for testing, I get the following error:

arch -x86_64 npm install @pact-foundation/pact-node
npm ERR! code EBADPLATFORM
npm ERR! notsup Unsupported platform for @pact-foundation/pact-node@10.11.8: wanted {"os":"darwin,linux,win32","arch":"x64,ia32"} (current: {"os":"darwin","arch":"arm64"})
npm ERR! notsup Valid OS:    darwin,linux,win32
npm ERR! notsup Valid Arch:  x64,ia32
npm ERR! notsup Actual OS:   darwin
npm ERR! notsup Actual Arch: arm64

I have tried with node 12 and node 15. / I have tried to specify arch x86_64 to run on rosseta2, but I think the issue is the call to the binary form js, would need to specify that flag if the architecture is darwin / arm64 pass the arch flag when calling the binary file to run it through rosetta2.

Any other workarounds that you suggest?

Thanks,
Pedro

@pedropaf pedropaf changed the title Support installati on Mac M1 ARM (using rosseta2) Support installati on Mac M1 ARM (using rosetta2) Feb 11, 2021
@pedropaf pedropaf changed the title Support installati on Mac M1 ARM (using rosetta2) Support installation on Mac M1 ARM (using rosetta2) Feb 11, 2021
@TimothyJones
Copy link
Contributor

So, we don’t currently have M1 binaries (or an M1 machine to test on, but I’m sure that will change). Travelling ruby has just been updated, so we might be able to make M1 binaries with that.

I think this error is coming from npm, not from pact-node (although it is following the restriction in pact-node’s package.json). From the npm docs, it looks like you’re running the arm version of npm. I think you’ll need to run the x86 version of node to install it- sounds like this is possible/easiest through running your terminal through Rosetta (although I may be wrong, I have only just started reading about it).

@TimothyJones
Copy link
Contributor

It's very possible that there will be issues with the way we are invoking the binary at the moment, but I am pretty sure the error you're currently getting is from npm deciding whether or not to let you install the package, based on comparing the value of process.arch to pact-node's cpu field in package.json.

If you have the time, it might be easiest to jump on slack together and see what we can do to get this going- I'm around tomorrow morning AEDT (UTC+11) -and plenty of other times if that doesn't work.

@pedropaf
Copy link
Author

Thanks, @TimothyJones for the update, I'm happy to jump into a call on GMT timezone.

@fimak
Copy link

fimak commented Mar 3, 2021

@pedropaf @TimothyJones
How it was, did you find a solution?

@obiSerra
Copy link

hello, there is any news on this issue? I'm having the same problem

@TimothyJones
Copy link
Contributor

We haven't had a chance to look at it yet. My gut says it's an npm configuration issue, rather than a pact-node issue, but I don't have an M1 machine to test it on.

@obiSerra
Copy link

obiSerra commented Mar 15, 2021

@TimothyJones I managed to investigate a bit more on this and the problem seems to be on pact-js-core where there are some checks to install the ruby binaries. The binaries work fine on my Apple m1, but the package.json configuration and the checksum performed on install.ts prevent the installation

@obiSerra
Copy link

I opened a PR with a possible fix #271

@TimothyJones
Copy link
Contributor

TimothyJones commented Mar 15, 2021 via email

@obiSerra
Copy link

I tested it on my computer and the mac binaries (https://github.com/pact-foundation/pact-ruby-standalone/releases/download/v1.88.41/pact-1.88.41-osx.tar.gz) seem to work fine; the problem was the check done by npm.

I added the checksum download because the install process was failing on that: the install process was checking for the checksum inside the standalone directory but wasn't able to find it there.

Unfortunately, I'm pretty new to pact-js and to the application we are using it on: I'm just picking up the project and I need to port it to our new Mac; so I'm not able to test it properly and to check against the version we used on the old machines

@TimothyJones
Copy link
Contributor

I'll summarise what I think is happening - and forgive me if this is not how it works on M1, I don't have one to test, and I'm not really sure how rosetta works. Corrections welcome.

I think the issue is that when you are running npm through rosetta, it is incorrectly failing the check for os in package.json, because npm is reporting the wrong value of arm64.

To work around this, we can add arm64 to the package.json, but this would not be correct, because we don't have arm64 binaries. As I understand it, adding arm64 to package.json would mean that people running npm natively (without rosetta) would have failures when they try to use the package.

I think this is a bug in npm, which should not be rejecting a darwin compatible package when running through rosetta.

@TimothyJones
Copy link
Contributor

Doing a bit more digging, I think that it looks like you need to install npm under rosetta. There are instructions here (although they are for cypress, this is the same issue). See: https://www.cypress.io/blog/2021/01/20/running-cypress-on-the-apple-m1-silicon-arm-architecture-using-rosetta-2/

@TimothyJones
Copy link
Contributor

^ Could someone try the above, and let us know if it works? If so, I'll add it to the documentation until we have M1 binaries.

@obiSerra
Copy link

Thank you, I followed the instruction you sent to me, and it worked

@erithmetic
Copy link

Alternatively, you can run everything in docker, which can run it in amd64 mode: https://erica.works/docker-on-mac-m1/

@konalegi
Copy link
Contributor

konalegi commented May 26, 2021

any updates here? Can I help somehow?

Alternatively, you can run everything in docker, which can run it in amd64 mode: https://erica.works/docker-on-mac-m1/\

Unfortunately, this is a bad option for my setup it's 4 times slower than in arm64 mode.

@mefellows
Copy link
Member

I'm not across the problem, but if you're willing to look into the details for us that would be helpful.

None of the maintainers currently have access to an M1 machine. It seems that docker should be a workaround, albeit not ideal, as well as using some other intel based workaround as per the Cypress blog.

If we can codify this and hide some of it from users, this would be great.

The core of the problem is that we use Ruby binaries (and soon to be Rust libraries) as our shared core. These need to be able to support the M1 chip.

@fidalgodev
Copy link

Having the same issue.
The fix was to delete the Node version the project was using with nvm, then run terminal in Rosetta mode inside the project folder, install the node version the project is using with the terminal in Rosetta mode (this will install node x64 instead of ARM version), and then I can run yarn fine.

Would be nice if this package could support node ARM tho.

@johanneswuerbach
Copy link
Contributor

johanneswuerbach commented Jul 5, 2021

I've investigate a bit, how to build arm64 binaries, but there seems to be a lot of exploration and work left 😢 .

Therefor I think just allowing rosetta to run the current binaries would be a really good usability improvement #302 as it just works if you have rosetta2 installed. I agree its not ideal, but teaching the current workaround to our developers and every new one seems worse 🤔 .

@mefellows mefellows pinned this issue Jul 19, 2021
@johanneswuerbach
Copy link
Contributor

This should no longer be required since pact-node@10.13.1 / pact-core@11.1.0 as the cpu limitation was removed #302

Now pact should just work ™️ with an arm node and rosetta installed 🎉. Thanks @TimothyJones

@TimothyJones
Copy link
Contributor

I think it’s still required, because allowing the arm64 install is a work around- we still don’t support that cpu yet. The workaround relies on the (currently) high probability that people with this cpu are on a mac that can translate the intel binary with Rosetta. It won’t work (I believe) for anyone (say) running Linux on that cpu.

I’d like to look at fixing this after the v3 release. It will be easier once we’re using the rust binaries, and hopefully at that point there will be M1 machines available in CI

@iknowcss
Copy link
Contributor

@TimothyJones
It won’t work (I believe) for anyone (say) running Linux on that cpu.

You're correct. One of the people on my team with an M1 Mac running a linux docker container without Rosetta gets this error during install:

Error: Error while installing binary: Cannot find binary for platform 'linux' with architecture 'arm64'.

Interestingly he is able to install and run the pact tests directly on the host without Rosetta 🤔

@iknowcss
Copy link
Contributor

Ah, sorry I just read the detail of #302. I guess the executable is running on Rosetta even though he is not running the node process under it.

@lawrenceong
Copy link

@iknowcss We are using Apple M1 as well. We usually run pact locally, either manually or on commit. To workaround the following error when building via docker:

Error: Error while installing binary: Cannot find binary for platform 'linux' with architecture 'arm64'.

We added the following to Dockerfile:

# Skipping pact binary install as it is not compatible with Apple M1 CPU
# See: https://github.com/pact-foundation/pact-js-core/issues/347
ENV PACT_SKIP_BINARY_INSTALL true

Can probably make it more comprehensive by detecting for CPU before setting it. Hope that helps.

regisb added a commit to overhangio/tutor-mfe that referenced this issue Mar 14, 2022
Additional requirements are required, and we cannot download the pact binary on
arm64: pact-foundation/pact-js-core#264

Close #31.
regisb added a commit to overhangio/tutor-mfe that referenced this issue Mar 14, 2022
Additional requirements are required, and we cannot download the pact binary on
arm64: pact-foundation/pact-js-core#264

Close #31.
regisb added a commit to overhangio/tutor-mfe that referenced this issue Apr 15, 2022
Additional requirements are required, and we cannot download the pact binary on
arm64: pact-foundation/pact-js-core#264

Close #31.
@mefellows
Copy link
Member

The latest version (13.x.x) should work on M1 natively as it ships an aarch64 shared module.

Previous versions (that bundle the Ruby core) can work under rosetta mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests