prisma / docs

📚 Prisma Documentation
https://www.prisma.io/docs
Apache License 2.0
983 stars 777 forks source link

Mac M1 Support #2549

Closed matthewmueller closed 2 minutes ago

matthewmueller commented 2 years ago

Right now you're unable to install the docs website locally on a Mac M1.

code 1
npm ERR! path /Users/tanaberry/Documents/GIT/prisma-docs/docs/node_modules/sharp
npm ERR! command failed
npm ERR! command sh -c (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)
npm ERR! CC(target) Release/obj.target/nothing/../node-addon-api/nothing.o
npm ERR!  LIBTOOL-STATIC Release/nothing.a
npm ERR!  TOUCH Release/obj.target/libvips-cpp.stamp
npm ERR!  CXX(target) Release/obj.target/sharp/src/common.o
npm ERR! info sharp Downloading https://github.com/lovell/sharp-libvips/releases/download/v8.10.5/libvips-8.10.5-darwin-arm64v8.tar.br
npm ERR! ERR! sharp Prebuilt libvips 8.10.5 binaries are not yet available for darwin-arm64v8
npm ERR! info sharp Attempting to build from source via node-gyp but this may fail due to the above error
npm ERR! info sharp Please see https://sharp.pixelplumbing.com/install for required dependencies
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@8.2.0
npm ERR! gyp info using node@16.13.0 | darwin | arm64
npm ERR! gyp info find Python using Python version 3.8.9 found at "/Library/Developer/CommandLineTools/usr/bin/python3"
npm ERR! gyp info spawn /Library/Developer/CommandLineTools/usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args  '/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args  'binding.gyp',
npm ERR! gyp info spawn args  '-f',
npm ERR! gyp info spawn args  'make',
npm ERR! gyp info spawn args  '-I',
npm ERR! gyp info spawn args  '/Users/tanaberry/Documents/GIT/prisma-docs/docs/node_modules/sharp/build/config.gypi',
npm ERR! gyp info spawn args  '-I',
npm ERR! gyp info spawn args  '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args  '-I',
npm ERR! gyp info spawn args  '/Users/tanaberry/Library/Caches/node-gyp/16.13.0/include/node/common.gypi',
npm ERR! gyp info spawn args  '-Dlibrary=shared_library',
npm ERR! gyp info spawn args  '-Dvisibility=default',
npm ERR! gyp info spawn args  '-Dnode_root_dir=/Users/tanaberry/Library/Caches/node-gyp/16.13.0',
npm ERR! gyp info spawn args  '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args  '-Dnode_lib_file=/Users/tanaberry/Library/Caches/node-gyp/16.13.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args  '-Dmodule_root_dir=/Users/tanaberry/Documents/GIT/prisma-docs/docs/node_modules/sharp',
npm ERR! gyp info spawn args  '-Dnode_engine=v8',
npm ERR! gyp info spawn args  '--depth=.',
npm ERR! gyp info spawn args  '--no-parallel',
npm ERR! gyp info spawn args  '--generator-output',
npm ERR! gyp info spawn args  'build',
npm ERR! gyp info spawn args  '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info spawn make
npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! warning: /Library/Developer/CommandLineTools/usr/bin/libtool: archive library: Release/nothing.a the table of contents is empty (no object file members in the library define global symbols)
npm ERR! ../src/common.cc:24:10: fatal error: 'vips/vips8' file not found
npm ERR! #include <vips/vips8>
npm ERR!     ^~~~~~~~~~~~
npm ERR! 1 error generated.
npm ERR! make: *** [Release/obj.target/sharp/src/common.o] Error 1
npm ERR! gyp ERR! build error 
npm ERR! gyp ERR! stack Error: make failed with exit code: 2
npm ERR! gyp ERR! stack   at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
npm ERR! gyp ERR! stack   at ChildProcess.emit (node:events:390:28)
npm ERR! gyp ERR! stack   at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
npm ERR! gyp ERR! System Darwin 21.1.0
npm ERR! gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd /Users/tanaberry/Documents/GIT/prisma-docs/docs/node_modules/sharp
npm ERR! gyp ERR! node -v v16.13.0
npm ERR! gyp ERR! node-gyp -v v8.2.0
npm ERR! gyp ERR! not ok
npm ERR! A complete log of this run can be found in:
npm ERR!   /Users/tanaberry/.npm/_logs/2021-11-19T21_01_02_211Z-debug.log`

The problem appears to be because Gatsby wraps some binaries that aren't built for M1 yet. Hopefully it's just bumping some dependencies for M1 support.

So far we've discovered:

  1. puppeteer downloads a chromium that's incompatible with M1 (not sure what dependency introduces puppeteer)
  2. our version sharp requires an incompatible libvips. This is documented in Gatsby's 3.3 release notes
keerlu commented 2 years ago

Just for reference, I'm currently working round this by:

Looking at my history I think that was all I had to do

tanberry commented 2 years ago

I did do the puppeteer/chromium steps, and got chromium installed, and I ran the brew install vips command thoguh it failed. The command npm install still kept failing. All errors seemed to be about dependencies, so searching StackOverflow led me to a couple of options: 1) downgrade to npm version 6, or 2) run npm install with the --legacy-peer-deps flag. That actually worked, and I was able to build locally and access the docs at http://localhost:8000/reference. (https://stackoverflow.com/questions/66239691/what-does-npm-install-legacy-peer-deps-do-exactly-when-is-it-recommended-wh)

tl;dr I am going to stick my assertion that our docs eco-system is far too complex. I'd like to eventually consider using something less heavy than Gatsby, for starters.

ankur-arch commented 2 minutes ago

Outdated.