mdn / developer-portal

The code that generates the MDN Web Docs Developer Portal.
Mozilla Public License 2.0
62 stars 38 forks source link

[Local dev] Address node-gyp build issues #1219

Open stevejalim opened 4 years ago

stevejalim commented 4 years ago

After bumping to node 12.16.1 I noticed that node-gyp was failing to build, and - indeed - because it's a non-fatal build issue, the cached version of the docker image/shard may well have not been building correctly for ages. Rolling back to 12.14 and doing a full rebuild shows the same kind of error.

Am [now] building on MacOS Catalina 10.15.3, but still using bash as my shell, not zsh yet.

I don't think we need node-gyp for anything Node-related right now, but - naturally - it would be good to get this behaving correctly soon.

Relevant output:

> node-gyp rebuild

gyp ERR! find Python
gyp ERR! find Python Python is not set from command line or npm configuration
gyp ERR! find Python Python is not set from environment variable PYTHON
gyp ERR! find Python checking if "python" can be used
gyp ERR! find Python - "python" is not in PATH or produced an error
gyp ERR! find Python checking if "python2" can be used
gyp ERR! find Python - "python2" is not in PATH or produced an error
gyp ERR! find Python checking if "python3" can be used
gyp ERR! find Python - "python3" is not in PATH or produced an error
gyp ERR! find Python
gyp ERR! find Python **********************************************************
gyp ERR! find Python You need to install the latest version of Python.
gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
gyp ERR! find Python you can try one of the following options:
gyp ERR! find Python - Use the switch --python="/path/to/pythonexecutable"
gyp ERR! find Python   (accepted by both node-gyp and npm)
gyp ERR! find Python - Set the environment variable PYTHON
gyp ERR! find Python - Set the npm configuration variable python:
gyp ERR! find Python   npm config set python "/path/to/pythonexecutable"
gyp ERR! find Python For more information consult the documentation at:
gyp ERR! find Python https://github.com/nodejs/node-gyp#installation
gyp ERR! find Python **********************************************************
gyp ERR! find Python
gyp ERR! configure error
gyp ERR! stack Error: Could not find any Python installation to use
gyp ERR! stack     at PythonFinder.fail (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:307:47)
gyp ERR! stack     at PythonFinder.runChecks (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:136:21)
gyp ERR! stack     at PythonFinder.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:179:16)
gyp ERR! stack     at PythonFinder.execFileCallback (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:271:16)
gyp ERR! stack     at exithandler (child_process.js:310:5)
gyp ERR! stack     at ChildProcess.errorhandler (child_process.js:322:5)
gyp ERR! stack     at ChildProcess.emit (events.js:311:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:273:12)
gyp ERR! stack     at onErrorNT (internal/child_process.js:469:16)
gyp ERR! stack     at processTicksAndRejections (internal/process/task_queues.js:84:21)
gyp ERR! System Linux 4.19.76-linuxkit
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /app/node_modules/fsevents
gyp ERR! node -v v12.16.1
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok
stevejalim commented 4 years ago

@peterbe @escattone @Gregoor @schalkneethling - if any of you have seen this issue before (am assuming Kuma or Yari might also be using Dockerised node-alpine) I'd welcome any pointers!

peterbe commented 4 years ago

@callahad Looked into this for Kuma and wasn't it a problem that node-gyp expects there to be a python version that is <3.8.

stevejalim commented 4 years ago

Ah, is that inside the Docker image or on the host? It looks like the latter, but am not 100%

Either way, default/py2 is 2.7.15, while py3 is 3.7.3, so that should be fine. Strange.

callahad commented 4 years ago

Search for node-gyp in the Kuma repo to turn up an explanation; too sick to go do that myself :(

Iirc, node-gyp only supports Py2

On Wed, Mar 11, 2020, 14:22 Steve Jalim notifications@github.com wrote:

Ah, is that inside the Docker image or on the host? It looks like the latter, but am not 100%

Either way, default/py2 is 2.7.15, while py3 is 3.7.3, so that should be fine. Strange.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/mdn/developer-portal/issues/1219#issuecomment-597663154, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAF5AM475IEL6KY7EWMMZTRG6NDFANCNFSM4LFUPNQQ .

peterbe commented 4 years ago

You don't have Python when you're building node-gyp. It's exclusively just node-alpine at that point. That means you can't expect node-gyp to compile its binaries so it'll fall back on the non-binary version of whatever needs it.

These kinds of problems would go away if we could use Docker base images that have both Node and Python in them. Kuma has that but it's also seems to cost us a bit since it needs do all the gpg stuff each time.

stevejalim commented 4 years ago

Ah that's interesting @peterbe . I guess it also suggests that this NEVER worked, then....