After upgrade, ghost now crashing

I tried upgrading my Ghost install from 4.36.1 to 4.41.3, but it fails to run.

With ghost running, the page just stays on the “We’ll be right back” message but in the /ghost/content/logs directory, there’s this in the production error log:

{"name":"Log","hostname":"domainremoved","pid":2352271,"level":50,"err":{"id":"8fec50b0-aa99-11ec-8044-e7767faa5190","domain":"http://localhost:2368","code":null,"name":"InternalServerError","statusCode":500,"level":"critical","message":"Knex: run\n$ npm install mysql2 --save\nEEXIST: file already exists, uv_pipe_open","stack":"Error: Knex: run\n$ npm install mysql2 --save\n$ npm install mysql2 --save\nEEXIST: file already exists, uv_pipe_open\n    at Client_MySQL2.initializeDriver (/node/16/lib/node_modules/knex/lib/client.js:235:13)\n    at Client_MySQL2.Client (/node/16/lib/node_modules/knex/lib/client.js:69:10)\n    at Client_MySQL2.Client_MySQL (/node/16/lib/node_modules/knex/lib/dialects/mysql/index.js:20:10)\n    at new Client_MySQL2 (/node/16/lib/node_modules/knex/lib/dialects/mysql2/index.js:11:16)\n    at Knex (/node/16/lib/node_modules/knex/lib/knex.js:14:28)\n    at Object.connect (/node/16/lib/node_modules/knex-migrator/lib/database.js:35:12)\n    at KnexMigrator.isDatabaseOK (/node/16/lib/node_modules/knex-migrator/lib/index.js:566:32)\n    at DatabaseStateManager.getState (/public_html//ghost/core/server/data/db/state-manager.js:40:37)\n    at DatabaseStateManager.makeReady (/public_html//ghost/core/server/data/db/state-manager.js:73:36)\n    at initDatabase (/public_html/ghost/core/boot.js:60:26)\n    at bootGhost (/public_html/ghost/core/boot.js:394:15)","hideStack":false},"msg":"Knex: run\n$ npm install mysql2 --save\nEEXIST: file already exists, uv_pipe_open","time":"2022-03-23T11:08:26.302Z","v":0}

I was using Nodejs 14.18.3 before and it worked fine, I haven’t upgraded the node version. I also had 16.13.2 on the system that I use for another app so tried using that too but I get the same error.

The upgrade seemed to go smooth enough (I have to do it manually as I can’t run ghost-cli), ran the knex-migrator migration after checking health which completed successfully but it seems there’s some issue with knex running npm install mysql2 --save when that already exists (I actually use MariaDB 10.3.34), though I’ve been manually upgrading Ghost for over two years and never had this sort of issue before.

Edit: I did attempt to revert back to 4.36.1 using a full backup but that wouldn’t work however I’ve tried reinstalling it the way I’d normally do an install/upgrade manually, using node 14.18.3 and a backup of the database prior to using knex-migrator and I now have my site back up and running again, so I can only assume this issue is something to do with newer ghost versions and the slightly older node versions?

For any future googlers coming across this while searching for the same/similar issues, I couldn’t figure out how to fix the problem but I did discover why it was apparently happening (sort of); because of a change in Ghost 4.38.0 - they switched from mysql to mysql2 libraries in that version of Ghost and versions prior to 4.38.0 install without issue.

It could just be the nodejs version was too old and causing the problem (it’s only a few months out of date but even so, I have had issues in the past when updating caused by the node version I was using, nothing this bad though).

I was able to install the ghost version immediately prior to 4.38.0 and it worked fine so that pretty much confirms it in my eyes that it was the mysql2 change that borked my install. I have noticed though my host made a few changes recently that I didn’t know about that will allow me to install and use ghost-cli now so I am hopeful I can just install, run and update ghost that way from now on.

Edit: I was indeed able to use ghost-cli. Unfortunately can’t use ghost from 4.38.0 or up still for the exact same reasons as above. It installs all ok, apparently, but upon running ghost it just has that same internal server error in the log.

Knex: run\n$ npm install mysql2 --save\nEEXIST: file already exists, uv_pipe_open

I thought maybe I’d switch to using sqlite instead, however doing this causes a different error when starting the ghost instance about it not being able to find the @vscode/sqlite3 node module. I found a raised issue where this was recently talked about on the tyryghost github issue tracker but couldn’t understand how to correct the issue.

I tried installing it via npm but it fails with node-gyp not being able to find python. Fixed that by pointing npm to where python is and then node-gyp fails saying python isn’t the right version. SInce shared hosting I can’t update python that’s on the server but I do have access to python selector virtual enviroments so I set one of those up to use python 3.7, then entered it, then entered the nodejs virtual environment I’ve been using, did all the above again and this time node-gyp found python ok and seemed to not be complaining about version numbers but then craps out with a different error about it not being able to find python, again (file not found error in the path where python 3.7 actually is). So quite frankly, I give up.

1 Like