pelias / whosonfirst

Importer for Who's on First gazetteer
MIT License
26 stars 42 forks source link

Upgrade `better-sqlite3` to v8.5.0 #536

Closed orangejulius closed 1 year ago

orangejulius commented 1 year ago

This helps with support for newer Node.js versions (https://github.com/pelias/pelias/issues/950)

missinglink commented 1 year ago

The CI is failing due to a lack of python3, not sure what changed here, maybe either the linux base image or our base image?

npm ERR! gyp ERR! find Python 
npm ERR! gyp ERR! find Python Python is not set from command line or npm configuration
npm ERR! gyp ERR! find Python Python is not set from environment variable PYTHON
npm ERR! gyp ERR! find Python checking if "python3" can be used
npm ERR! gyp ERR! find Python - "python3" is not in PATH or produced an error
npm ERR! gyp ERR! find Python checking if "python" can be used
npm ERR! gyp ERR! find Python - "python" is not in PATH or produced an error
npm ERR! gyp ERR! find Python 
npm ERR! gyp ERR! find Python **********************************************************
npm ERR! gyp ERR! find Python You need to install the latest version of Python.
npm ERR! gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
npm ERR! gyp ERR! find Python you can try one of the following options:
npm ERR! gyp ERR! find Python - Use the switch --python="/path/to/pythonexecutable"
npm ERR! gyp ERR! find Python   (accepted by both node-gyp and npm)
npm ERR! gyp ERR! find Python - Set the environment variable PYTHON
npm ERR! gyp ERR! find Python - Set the npm configuration variable python:
npm ERR! gyp ERR! find Python   npm config set python "/path/to/pythonexecutable"
npm ERR! gyp ERR! find Python For more information consult the documentation at:
npm ERR! gyp ERR! find Python https://github.com/nodejs/node-gyp#installation
npm ERR! gyp ERR! find Python **********************************************************
npm ERR! gyp ERR! find Python 
npm ERR! gyp ERR! configure error 
orangejulius commented 1 year ago

Yeah, there are no pre-built better-sqlite3 binaries for Node.js 12 (since it's EOL), so python3 is required to build it. But a while back we removed the compiler toolchain from our base images, and I'd rather keep it removed.

Once we update the Docker baseimage from Node.js 12 to Node.js 16, we should be fine.

orangejulius commented 1 year ago

Our Docker images are now built using Node.js 16, but the Docker build still fails because apparently better-sqlite3 version 8.4.0 also requires Ubuntu 20+. So we have to handle https://github.com/pelias/pelias/issues/951 before merging this.

orangejulius commented 1 year ago

Everything Ubuntu 22 related is taken care of, so this PR can now be merged and we can start to update better-sqlite3 everywhere else. Hopefully this makes it quick and easy for everyone on modern operating systems and Node.js versions to run npm install as they won't have to compile better-sqlite3 and can instead rely on prebuilds.

Also, better-sqlite3 8.5.0 was just released so I've bumped up the version in this PR.