Attempt to Upgrade 2 to 3 fails

I’m trying to update Ghost 2.2.3 to Ghost 3.12.1 using ghost-cli 1.13.1.

Install Log:

ghost-mgr@lamarche:/var/www/ghost$ ghost update
+ sudo systemctl is-active ghost_lamarche-photography
✔ Checking system Node.js version
✔ Ensuring user is not logged in as ghost user
✔ Checking if logged in user is directory owner
✔ Checking current folder permissions
✔ Checking folder permissions
✔ Checking file permissions
✔ Checking content folder ownership
✔ Checking memory availability
✔ Checking for available migrations
✔ Checking for latest Ghost version
✔ Downloading and updating Ghost to v3.12.1


Checking theme compatibility for Ghost 3.12.1

✔ Your theme is compatible.

You can also check theme compatibility at https://gscan.ghost.org

? Are you sure you want to proceed with migrating to Ghost 3.12.1? Yes
✔ Updating to a major version
+ sudo systemctl stop ghost_lamarche-photography
✔ Stopping Ghost
✔ Linking latest Ghost and recording versions
+ sudo systemctl start ghost_lamarche-photography
+ sudo systemctl stop ghost_lamarche-photography
✖ Restarting Ghost
A GhostError occurred.

Message: Could not communicate with Ghost
Suggestion: journalctl -u ghost_lamarche-photography -n 50

Debug Information:
    OS: Ubuntu, v18.04.4 LTS
    Node Version: v12.16.1
    Ghost Version: 3.12.1
    Ghost-CLI Version: 1.13.1
    Environment: production
    Command: 'ghost update'

Additional log info available in: /home/ghost-mgr/.ghost/logs/ghost-cli-debug-2020-04-01T16_15_42_854Z.log

Try running ghost doctor to check your system for known issues.

You can always refer to https://ghost.org/docs/api/ghost-cli/ for troubleshooting.



? Unable to upgrade Ghost from v2.22.3 to v3.12.1. Would you like to revert back to v2.22.3? Yes
+ sudo systemctl is-active ghost_lamarche-photography
+ sudo systemctl reset-failed ghost_lamarche-photography
✔ Checking system Node.js version
✔ Ensuring user is not logged in as ghost user
✔ Checking if logged in user is directory owner
✔ Checking current folder permissions
✔ Checking folder permissions
✔ Checking file permissions
✔ Checking content folder ownership
✔ Checking for available migrations
✔ Checking for latest Ghost version
ℹ Downloading and updating Ghost [skipped]
+ sudo /var/www/ghost/current/node_modules/.bin/knex-migrator-rollback --force --v 2.22.3 --mgpath /var/www/ghost/current
✔ Rolling back database migrations
✔ Linking latest Ghost and recording versions
+ sudo systemctl start ghost_lamarche-photography
✔ Restarting Ghost
ℹ Removing old Ghost versions [skipped]
ghost-mgr@lamarche:/var/www/ghost$ cat /home/ghost-mgr/.ghost/logs/ghost-cli-debug-2020-04-01T16_15_42_854Z.log
Debug Information:
    OS: Ubuntu, v18.04.4 LTS
    Node Version: v12.16.1
    Ghost Version: 3.12.1
    Ghost-CLI Version: 1.13.1
    Environment: production
    Command: 'ghost update'
Message: Could not communicate with Ghost
Suggestion: journalctl -u ghost_lamarche-photography -n 50
Stack: Error: Could not communicate with Ghost
    at Server.<anonymous> (/usr/local/lib/node_modules/ghost-cli/lib/utils/port-polling.js:56:20)
    at Object.onceWrapper (events.js:417:28)
    at Server.emit (events.js:311:20)
    at emitCloseNT (net.js:1653:8)
    at processTicksAndRejections (internal/process/task_queues.js:83:21)

Contents of /home/ghost-mgr/.ghost/logs/ghost-cli-debug-2020-04-01T16_15_42_854Z.log

Debug Information:
    OS: Ubuntu, v18.04.4 LTS
    Node Version: v12.16.1
    Ghost Version: 3.12.1
    Ghost-CLI Version: 1.13.1
    Environment: production
    Command: 'ghost update'
Message: Could not communicate with Ghost
Suggestion: journalctl -u ghost_lamarche-photography -n 50
Stack: Error: Could not communicate with Ghost
    at Server.<anonymous> (/usr/local/lib/node_modules/ghost-cli/lib/utils/port-polling.js:56:20)
    at Object.onceWrapper (events.js:417:28)
    at Server.emit (events.js:311:20)
    at emitCloseNT (net.js:1653:8)
    at processTicksAndRejections (internal/process/task_queues.js:83:21)

ghost doctor is all green checkmarks.

I’ve attempted it multiple times, always the same result. It does revert fine, which is a relief, but I really have no idea where to even look on this.

Thanks!

Can you try this command and share the output?

I tried the update again, and then ran that command right after it failed. Results were a little more interesting. I still don’t know how to fix, though.

root@lamarche:~# journalctl -u ghost_lamarche-photography -n 50
-- Logs begin at Mon 2019-07-01 23:52:52 UTC, end at Wed 2020-04-01 19:56:56 UTC. --
Apr 01 19:51:48 lamarche systemd[1]: ghost_lamarche-photography.service: Scheduled restart job, restart counter is at 3.
Apr 01 19:51:48 lamarche systemd[1]: Stopped Ghost systemd service for blog: lamarche-photography.
Apr 01 19:51:48 lamarche systemd[1]: Started Ghost systemd service for blog: lamarche-photography.
Apr 01 19:51:49 lamarche node[16683]: - Inspecting operating system
Apr 01 19:51:50 lamarche node[16683]: /var/www/ghost/versions/3.12.1/node_modules/fs-extra/lib/mkdirs/make-dir.js:86
Apr 01 19:51:50 lamarche node[16683]:       } catch {
Apr 01 19:51:50 lamarche node[16683]:               ^
Apr 01 19:51:50 lamarche node[16683]: SyntaxError: Unexpected token {
Apr 01 19:51:50 lamarche node[16683]:     at createScript (vm.js:80:10)
Apr 01 19:51:50 lamarche node[16683]:     at Object.runInThisContext (vm.js:139:10)
Apr 01 19:51:50 lamarche node[16683]:     at Module._compile (module.js:616:28)
Apr 01 19:51:50 lamarche node[16683]:     at Object.Module._extensions..js (module.js:663:10)
Apr 01 19:51:50 lamarche node[16683]:     at Module.load (module.js:565:32)
Apr 01 19:51:50 lamarche node[16683]:     at tryModuleLoad (module.js:505:12)
Apr 01 19:51:50 lamarche node[16683]:     at Function.Module._load (module.js:497:3)
Apr 01 19:51:50 lamarche node[16683]:     at Module.require (module.js:596:17)
Apr 01 19:51:50 lamarche node[16683]:     at require (internal/module.js:11:18)
Apr 01 19:51:50 lamarche node[16683]:     at Object.<anonymous> (/var/www/ghost/versions/3.12.1/node_modules/fs-extra/lib/mkdirs/index.js:3:44)
Apr 01 19:51:50 lamarche systemd[1]: ghost_lamarche-photography.service: Service hold-off time over, scheduling restart.
Apr 01 19:51:50 lamarche systemd[1]: ghost_lamarche-photography.service: Scheduled restart job, restart counter is at 4.
Apr 01 19:51:50 lamarche systemd[1]: Stopped Ghost systemd service for blog: lamarche-photography.
Apr 01 19:51:50 lamarche systemd[1]: Started Ghost systemd service for blog: lamarche-photography.
Apr 01 19:51:51 lamarche node[16737]: - Inspecting operating system
Apr 01 19:51:52 lamarche node[16737]: /var/www/ghost/versions/3.12.1/node_modules/fs-extra/lib/mkdirs/make-dir.js:86
Apr 01 19:51:52 lamarche node[16737]:       } catch {
Apr 01 19:51:52 lamarche node[16737]:               ^
Apr 01 19:51:52 lamarche node[16737]: SyntaxError: Unexpected token {
Apr 01 19:51:52 lamarche node[16737]:     at createScript (vm.js:80:10)
Apr 01 19:51:52 lamarche node[16737]:     at Object.runInThisContext (vm.js:139:10)
Apr 01 19:51:52 lamarche node[16737]:     at Module._compile (module.js:616:28)
Apr 01 19:51:52 lamarche node[16737]:     at Object.Module._extensions..js (module.js:663:10)
Apr 01 19:51:52 lamarche node[16737]:     at Module.load (module.js:565:32)
Apr 01 19:51:52 lamarche node[16737]:     at tryModuleLoad (module.js:505:12)
Apr 01 19:51:52 lamarche node[16737]:     at Function.Module._load (module.js:497:3)
Apr 01 19:51:52 lamarche node[16737]:     at Module.require (module.js:596:17)
Apr 01 19:51:52 lamarche node[16737]:     at require (internal/module.js:11:18)
Apr 01 19:51:52 lamarche node[16737]:     at Object.<anonymous> (/var/www/ghost/versions/3.12.1/node_modules/fs-extra/lib/mkdirs/index.js:3:44)
Apr 01 19:51:52 lamarche systemd[1]: ghost_lamarche-photography.service: Service hold-off time over, scheduling restart.
Apr 01 19:51:52 lamarche systemd[1]: ghost_lamarche-photography.service: Scheduled restart job, restart counter is at 5.
Apr 01 19:51:52 lamarche systemd[1]: Stopped Ghost systemd service for blog: lamarche-photography.
Apr 01 19:51:52 lamarche systemd[1]: ghost_lamarche-photography.service: Start request repeated too quickly.
Apr 01 19:51:52 lamarche systemd[1]: ghost_lamarche-photography.service: Failed with result 'start-limit-hit'.
Apr 01 19:51:52 lamarche systemd[1]: Failed to start Ghost systemd service for blog: lamarche-photography.
Apr 01 19:56:47 lamarche systemd[1]: Started Ghost systemd service for blog: lamarche-photography.
Apr 01 19:56:48 lamarche node[16871]: - Inspecting operating system
Apr 01 19:56:52 lamarche node[16871]: [2020-04-01 19:56:52] INFO Ghost is running in production...

Here is the contents of /var/www/ghost/versions/3.12.1/node_modules/fs-extra/lib/mkdirs/index.js where the stack trace seems to have originated.

root@lamarche:~# cat /var/www/ghost/versions/3.12.1/node_modules/fs-extra/lib/mkdirs/index.js
'use strict'
const u = require('universalify').fromPromise
const { makeDir: _makeDir, makeDirSync } = require('./make-dir')
const makeDir = u(_makeDir)

module.exports = {
mkdirs: makeDir,
mkdirsSync: makeDirSync,
// alias
mkdirp: makeDir,
mkdirpSync: makeDirSync,
ensureDir: makeDir,
ensureDirSync: makeDirSync
}

I tried npm install make-dir, and then ran update again. Same result.

It looks like a bug in fs-extra (There’s an issue posted in the repo). Is it possible you’re running multiple versions of node?

Thank you. It is possible. How would I check that?

node -v run as both the ghost-user and root return the same value v12.16.1

Do you have nvm or any other node version management tool installed?

To check for nvm try nvm version and if it is installed please share the output from nvm which system.

Also could you share the output from which node and which nodejs? Thanks!

ghost-mgr@lamarche:~$ which node
/usr/local/bin/node
ghost-mgr@lamarche:~$ which nodejs
/usr/bin/nodejs

I’m guessing the fact that ones’s coming from /usr/bin and the other from /user/local/bin might be problematic?

I’m not entirely sure what package managers other than apt-get are installed, as the server came pre-configured with a bunch of stuff. The best I can tell, npm was pre-installed, but hadn’t been used to install anything until I used it to install make-dir after this problem happened. npm list shows only make-dir and its dependencies.

Does nvm version not output anything?

What does node -v and nodejs -v output?

Also what about npm list -g :thinking:

root@lamarche:~# npm version
{
npm: '6.13.4',
ares: '1.15.0',
brotli: '1.0.7',
cldr: '35.1',
http_parser: '2.9.3',
icu: '64.2',
llhttp: '2.0.4',
modules: '72',
napi: '5',
nghttp2: '1.40.0',
node: '12.16.1',
openssl: '1.1.1d',
tz: '2019c',
unicode: '12.1',
uv: '1.34.0',
v8: '7.8.279.23-node.31',
zlib: '1.2.11'
}

npm list -g outputs quite a lot. I can post it if it’s valuable, but it’s pages and pages long.

@jlamarche The command I posted was nVm version, not nPm. nvm is a tool that installs multiple node versions on your system - this is the most likely culprit.

From npm list -g it was a punt, I was wondering whether you had other similar tools like nave or n installed globally.

Sorry. I assumed it was a typo. My install doesn’t have nvm installed and apt-get install nvm returns “unable to locate package nvm”

I also asked for this please.

It’s likely you have a problem similar to what’s described on these 2 pages, am trying to confirm and exactly what and figure out which one you should get rid of :thinking:

I pasted it above, but here it is again - there is a mismatch:

ghost-mgr@lamarche:~$ which node
/usr/local/bin/node
ghost-mgr@lamarche:~$ which nodejs
/usr/bin/nodejs

Reading those questions, thank you. I’ll try their solutions.

node -v
nodejs -v

That’s different from which ... :wink:

Sorry, brain fart.

root@lamarche:/usr/local/bin# node -v
v12.16.1
root@lamarche:/usr/local/bin# nodejs -v
v13.12.0

So, I think I see (sort of) what’s going on. Ghost doesn’t support node v13, but there’s another app running under the same nginx instance that requires v13 and apparently installed node v13 in /usr/bin as a dependency. As of right now, everything is working - my Ghost 2.0 install uses /usr/local/bin/node and the other app uses node in /usr/bin/nodejs, so everything runs fine. However, ghost update, which validates against /usr/local/bin/nodejs and finds a supported version (v12) but then has an issue during restart after the upgrade because of the mismatch.

I honestly don’t know if there’s a way to fix this to allow the update without breaking one of the two apps.

I tried temporarily removing nodejs v13 from /usr/bin/ (using apt-get remove nodejs) It did not change the update process - it still hangs on restart, exactly the same as when there were mis-matched version of node and nodejs

The problem you’re having with ghost update is to do with the use of optional catch binding in fs-extra as outlined in the linked thread.

This is a Node.js feature that was added in Node v10. Ghost and many of its dependencies no longer supports Node.js < v10.

Somewhere on your system, there’s a version of Node.js < v10 causing this problem. Node v13 is not the problem.