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

Get real architecture of M1 Mac regardless of Rosetta #3514

Closed
wants to merge 2 commits into from

Conversation

Xheldon
Copy link

@Xheldon Xheldon commented Jan 4, 2023

Get real architecture of M1 Mac regardless of Rosetta or node version, see #3239

Get the real architecture of M1 Mac regardless of Rosetta to deal with HEIC image, see #3239
@lovell
Copy link
Owner

lovell commented Jan 4, 2023

Hi, thanks for taking the time to open a PR,

Are you able to explain a bit more about why this change is necessary, as the current logic is intentional and well-tested in the field.

Here's the background to why the isRosetta check exists in its current form:

#2460 (comment)

For Rosetta x64, it prevents the use of a globally-installed ARM64 libvips as this conflict with the use of x64 Node.js

On an M1/M2 based machine, the dylib files provided by a globally-installed vips (via Homebrew or otherwise) will be ARM64, therefore we cannot use these when running Node.js under x64 emulation as there will be a runtime conflict.

As an aside, I'll add a note to the docs about this at https://sharp.pixelplumbing.com/install#custom-libvips

@Xheldon
Copy link
Author

Xheldon commented Jan 4, 2023

Thanks for review this PR! @lovell

Let me explain the scenario I encountered. At first I wanted to convert the HEIC image format to PNG, but when I called the Sharp API it reported an error and prompted me Unsupport Feature , so I followed the prompts in this repository to install libvips globally.
But when I reinstalled Sharp, it still showing that I was not using global-installed libvips.
so I debugger the Sharp code, and when I step into the isRosetta function, I found that my 14.18.3 version of node installed via nvm is x64, and the value of sysctl sysctl.proc_translated is sysctl.proc_translated: 1.
After I installed the arm64 version of node(19.13.0), the problem was solved. So I'm trying to do a compatibility handling here, i.e. if node is x64, but the system is arm64, you still need to use globally-installed libvips.

After reading the introduction of isRosetta attached by you, I understand that my modification may be inappropriate, but please at least prompt the user in console to switch the x64 version of node to the native arm64 version, because I spent 1 hour on this to solve the HEIC to PNG conversion problem, thank you!

@lovell
Copy link
Owner

lovell commented Jan 4, 2023

Logging added and docs updated via commit 5be36c2

@lovell lovell closed this Jan 4, 2023
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

Successfully merging this pull request may close these issues.

2 participants