-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Can't compile under Apple Silicon M1 arm64 #2460
Comments
https://sharp.pixelplumbing.com/install#prebuilt-binaries You'll need to compile libvips from source and install it globally first. |
I was already using --build-from-source all the time and even tried SHARP_IGNORE_GLOBAL_LIBVIPS Should I try to compile libvips completely independent from npm as explained here? I thought npm install --build-from-source should take care of that ... |
Building libvips from source is independent of building sharp from source, so yes, you'll need to follow the libvips-provided instructions. We won't be able to provide any prebuilt binaries for Apple Silicon until a CI provider makes ARM64 macOS hardware available for free to open source. |
Unfortunately homebrew is not yet fully compatible with apple silicon as of Homebrew/brew#7857 if you have other ideas - I will be glad to try them out on the M1. I was able to compile many other node modules without any problem on Apple Silicon arm64, it's just the libvips that gives me an issue and stops me from completing the last step with the great node module sharp. Can I just copy the source from libvips so it gets picket up by the npm install --build-from-source ?
|
Actually I got bit further in compiling libvips under M1 arm64 but unfortunately got stuck in compiling dependencies like libglib2 which are totally unaware of the Mac arm64 and try to use Windows AARM64 So seems there is unfortunately a long way to go to make all this happen. As the guys from homebrew discovered and are working hard to get it all right. |
Well I finally managed to compile libvips with homebrew under apple arm64, but had to compile it without fftw, libmatio, librsvg and poppler fftw was requiring gcc as well libmatio, while librsvg needed rust which is not ready yet. trying to build everything statically now, but without luck due to the mentioned bug. are the prebuild binaries all build statically? Ideally we would like to add a prebuild binary. |
The prebuilt binaries for libvips and its (selected) dependencies as provided by sharp are statically linked into a single shared library that can then be dynamically linked to sharp itself. These are created by the scripts in https://github.com/lovell/sharp-libvips/ |
I'm interested in this topic as well, did anyone figure a way to get sharp running under Apple silicon m1? |
Confirmed from #2467 that this is a non-issue once you have |
@kenips - great to hear you manage to compile it globally! I managed only to compile it with brew, but had to leave a lot of dependencies away. Did you had to leave our some dependencies as well? Do you have more detailed procedure for the global install? Did you install additional building tools first on a virgin M1, like autoconf, confure and pkgconfig? |
I managed to run sharp thanks to @kenips comment
|
@gpetrov yes my procedure is very similar to @medhoover, however using homebrew:
I have installed a few packages prior to installing libvips, so there might be additional packages that I've missed for a mint install, so YMMV :). |
Those steps worked for me, thanks! Please note that I also needed to set the PKG_CONFIG_PATH env var when installing node modules. |
I was able to get it to work in the following ways with Node.js 15.3.0. brew install pkg-config glib zlib
brew install libjpeg-turbo libpng webp
# in the libvips source folder
PKG_CONFIG_PATH=/opt/homebrew/Cellar/zlib/1.2.11/lib/pkgconfig ./configure
make
sudo make install |
I ended up having to run it with to avoid some weird imagemagick/poppler issues (even when installed for arm):
If you're running into issues with x86 libraries, be sure to check your Edit: actually this one failed too, I'm getting this now, even though the directory exists:
Edit 2: Ended up being because I had a space in the libvips folder name due to downloading two of the same version 😞 Now at:
Any reason I've run into so many different issues? Trying a fresh download of libvips to see if perhaps I just messed up something, otherwise will continue mucking around. Edit: Deleted and re-downloaded libvips, its saying during configure and then failing now with mismatch arch. Somehow regressed on this..
|
🎉 I'm happy to report that thanks to the huge effort of the homebrew team and specially @fxcoudert, libvips can be fully installed on Apple Silicon M1 natively with all its dependencies! Also for the most of the dependencies prebuild binaries "bottles" are available so installation goes really fast
the same is valid for node and the sharp library now - they can run nicely native on M1 now! |
I had a similar issue with incompatibility with M1 chips at node installation time (none of the suggestions worked for me, not even reinstalling vips with 'apparently' full compatibility with M1):
My environment is the following:
Any idea? |
Your node_modules contain an old Mac x86 binary. You can delete them and do a fresh npm install |
I have the same problem as @cooknpop: deleting and reinstalling All I've done is:
I see this while
But then I got:
|
Check ~/.npm There's probably a sharp directory there. Try deleting it |
It might also help to remove any package-lock or yarn.lock files |
@abarisain, no such folder
|
@iksent Said that, my suggestion: I hope it will help. |
- For Rosetta x64, prevent use of global ARM64 libvips - For ARM64, improve error message when global libvips not found
Commit 4264c05, part of the forthcoming sharp v0.27.2, should improve the experience for those using Apple M1 devices.
From sharp v0.28.0 onwards, cross-compiled libvips binaries will be provided for As soon as GitHub Actions or a similar CI service makes the M1 freely available to open source projects then natively compiled and tested prebuilt |
Strapi uses sharp as a dependency under the hood . How to force to use the latest version ? I tried using resolution resolutions:{
"sharp":"0.27.2"
}
I think it worked if someone is having the same issue |
Hi everyone, |
I'm trying hard to stay on topic, but please don't follow this article. The advice there is bad: there is no good reason to run the terminal itself under rosetta. Performance will suffer for no reason. Why would the terminal emulator itself, along with its rendering engine, need to run under rosetta? It does not. f you really must use a rosetta'd shell, use something like "arch -x86_64 /bin/bash" Using nvm to install node < 15 will result in x64 node being installed, and rosetta will automatically take over. Using nvm ,even in an arm64 shell, to install node 14 or lower will automatically install a rosetta node, usable from your native arm64 shell. Sharp 0.27.2 also nudges you toward the best solution, which is installing libvips natively: rosetta can't translate all of libvips and you will encounter crashes when processing some files. It will also handle skipping system libvips when running in rosetta, so installing vips using homebrew doesn't block you from falling back on rosetta node. |
How to install node 14 without nvm ? |
@seloner just try to install node in the Rosetta mode following the official documentation. |
@abarisain |
I'm not saying to use native node, I'm saying to use rosetta'd node using other ways rather than running the whole terminal under rosetta, which will destroy its performance. "nvm install 14" will install a x86_64 node, even on arm64. Only for node 15 you'd need some kind of workaround (like "arch -x86_64 /bin/bash -c nvm install 15") Last time I get off topic, sorry. |
Using nvm you will only run node only under rosetta and not the whole terminal |
Sorry for getting off topic again!. |
Please subscribe to #2604 to track the provision of I'll close this issue as it's drifting somewhat off-topic but has been valuable nonetheless, thank you all for your participation. |
I accidentally came to this problem as I am trying to install I am using mac M1 and node 14.x Appreciate your help. |
sharp v0.28.0 is now available and provides prebuilt (cross-compiled) libvips binaries for Apple M1 (darwin-arm64v8) so you no longer need to install vips via Homebrew. https://sharp.pixelplumbing.com/install#apple-m1 Xcode and Python are still required as sharp must be built from source. As soon as GitHub Actions or a similar CI service makes M1-based machines freely available to open source projects then natively compiled and tested prebuilt darwin-arm64 binaries will also be provided for sharp. |
What should we do? any direct advise? |
you can build mac arm on intel, so infrastructure change is not really needed. Google Chromium describes it well: https://chromium.googlesource.com/chromium/src/+/master/docs/mac_arm64.md |
That's what has been done for libvips. Cross compiling the node library looks way more difficult. It might not be, but I didn't manage to do it. Missing those prebuilts isn't a big deal that said, you most likely rely on dev tools being installed for other stuff (like homebrew itself, or any node gyp module) |
A bit lost here; do you mean the brew installation folder, or each and every node_modules directory? (If we have 30 could be boring haha) |
Please can everyone using Apple M1 devices upgrade to sharp v0.28.0, which removes the need to install/compile things via Homebrew. Even better, please can you open PRs to update any downstream packages (such as cordova-res) that are still using older versions. https://sharp.pixelplumbing.com/install#apple-m1 I'm going to lock this issue now. If you're still having problems, please open a new installation issue and answer all of the questions. |
Did you see the documentation relating to installation?
Have you ensured the architecture and platform of Node.js used for
npm install
is the same as the architecture and platform of Node.js used at runtime?Are you using the latest version? Is the version currently in use as reported by
npm ls sharp
the same as the latest version as reported bynpm view sharp dist-tags.latest
?What is the complete output of running
npm install --verbose sharp
? Have you checked this output for useful error messages?Seems somehow libvips can't be compiled from source
Any ideas?
The text was updated successfully, but these errors were encountered: