Ghost update fails (exit code: 127)

Hi everyone,

I have been using Ghost for quite a while, right now I have about 5 websites running it on my server:

Ubuntu 20.04.6 LTS

Suddenly I started having some issues when upgrading ghost where it won’t start after that …

I am running NodeJS: v18.16.0

The current issue I have seems to be related to npm permissions, which is interesting since other instances are working? I also keep getting messages about “chalk” missing and so on …

If this helps, this is the snippet of the last failed attempt at updating from 5.47.0 > 5.47.1

I run ghost doctor and everything “seems ok”

:heavy_check_mark: Checking system Node.js version - found v18.16.0

:heavy_check_mark: Checking logged in user

:heavy_check_mark: Ensuring user is not logged in as ghost user

:heavy_check_mark: Checking if logged in user is directory owner

:heavy_check_mark: Checking current folder permissions

:heavy_check_mark: Checking system compatibility

:heavy_check_mark: Checking for a MySQL installation

  • sudo systemctl is-active ghost_photo-marcobicca-com

:heavy_check_mark: Validating config

:heavy_check_mark: Checking folder permissions

:heavy_check_mark: Checking file permissions

:heavy_check_mark: Checking content folder ownership

:heavy_check_mark: Checking memory availability

:heavy_check_mark: Checking binary dependencies

:heavy_check_mark: Checking free space

:heavy_check_mark: Checking system unit file

:heavy_check_mark: Checking system node version - found v18.16.0

Then I ran:

$ ghost update --force

  • sudo systemctl is-active ghost_photo-marcobicca-com

:heavy_check_mark: Checking system Node.js version - found v18.16.0

:heavy_check_mark: Ensuring user is not logged in as ghost user

:heavy_check_mark: Checking if logged in user is directory owner

:heavy_check_mark: Checking current folder permissions

:heavy_check_mark: Checking folder permissions

:heavy_check_mark: Checking file permissions

:heavy_check_mark: Checking content folder ownership

:heavy_check_mark: Checking memory availability

:heavy_check_mark: Checking free space

:heavy_check_mark: Checking for available migrations

:heavy_check_mark: Checking for latest Ghost version

5.47.1

  • :art: Updated Casper to v5.4.11 - Ghost CI

  • :bug: Fixed site setup hanging when mail isn’t configured - Fabien ‘egg’ O’Carroll

  • :bug: Fixed generating card assets with include allowlist (#16766) - Deepam Kapur

  • :bug: Fixed Member signup when signup terms are null - Fabien “egg” O’Carroll


:heavy_check_mark: Fetched release notes

:heavy_multiplication_x: Downloading and updating Ghost to v5.47.1

A ProcessError occurred.

Message: Command failed: yarn install --no-emoji --no-progress

warning ghost[AT]5.47.1: The engine “cli” appears to be invalid.

warning Resolution field “[AT]elastic/elasticsearch[AT]8.5.0” is incompatible with requested version “[AT]elastic/elasticsearch[AT]8.6.0”

warning Resolution field “moment[AT]2.24.0” is incompatible with requested version “moment[AT]^2.29.1”

warning Resolution field “[AT]tryghost/errors[AT]1.2.24” is incompatible with requested version “[AT]tryghost/errors[AT]1.2.21”

warning Resolution field “moment[AT]2.24.0” is incompatible with requested version “moment[AT]2.29.1”

warning Resolution field “moment[AT]2.24.0” is incompatible with requested version “moment[AT]^2.27.0”

warning Resolution field “moment-timezone[AT]0.5.23” is incompatible with requested version “moment-timezone[AT]^0.5.31”

warning Resolution field “moment[AT]2.24.0” is incompatible with requested version “moment[AT]2.29.4”

warning Resolution field “moment[AT]2.24.0” is incompatible with requested version “moment[AT]2.29.4”

warning Resolution field “moment-timezone[AT]0.5.23” is incompatible with requested version “moment-timezone[AT]0.5.34”

warning Resolution field “[AT]tryghost/errors[AT]1.2.24” is incompatible with requested version “[AT]tryghost/errors[AT]1.2.21”

warning Resolution field “moment[AT]2.24.0” is incompatible with requested version “moment[AT]2.29.1”

warning Resolution field “moment[AT]2.24.0” is incompatible with requested version “moment[AT]2.29.3”

warning Resolution field “moment-timezone[AT]0.5.23” is incompatible with requested version “moment-timezone[AT]^0.5.33”

warning Resolution field “moment[AT]2.24.0” is incompatible with requested version “moment[AT]2.27.0”

warning Resolution field “[AT]tryghost/errors[AT]1.2.24” is incompatible with requested version “[AT]tryghost/errors[AT]1.2.25”

warning Resolution field “[AT]tryghost/logging[AT]2.4.4” is incompatible with requested version “[AT]tryghost/logging[AT]2.4.5”

warning Resolution field “[AT]tryghost/logging[AT]2.4.4” is incompatible with requested version “[AT]tryghost/logging[AT]^2.4.5”

warning Resolution field “[AT]tryghost/errors[AT]1.2.24” is incompatible with requested version “[AT]tryghost/errors[AT]1.2.25”

warning Resolution field “[AT]tryghost/logging[AT]2.4.4” is incompatible with requested version “[AT]tryghost/logging[AT]2.4.5”

warning Resolution field “moment[AT]2.24.0” is incompatible with requested version “moment[AT]^2.29.1”

warning “[AT]tryghost/kg-lexical-html-renderer > [AT]lexical/rich-text[AT]0.10.0” has unmet peer dependency “[AT]lexical/selection[AT]0.10.0”.

warning “[AT]tryghost/kg-lexical-html-renderer > [AT]lexical/rich-text[AT]0.10.0” has unmet peer dependency “[AT]lexical/utils[AT]0.10.0”.

warning " > bookshelf[AT]1.2.0" has incorrect peer dependency “knex[AT]>=0.15.0 <0.22.0”.

error /var/www/photo/versions/5.47.1/node_modules/re2: Command failed.

Exit code: 127

Command: install-from-cache --artifact build/Release/re2.node --host-var RE2_DOWNLOAD_MIRROR --skip-path-var RE2_DOWNLOAD_SKIP_PATH --skip-ver-var RE2_DOWNLOAD_SKIP_VER || npm run rebuild

Arguments:

Directory: /var/www/photo/versions/5.47.1/node_modules/re2

Output:

Trying https://github.com/uhop/node-re2/releases/download/1.18.0/linux-x64-108.br

Writing to build/Release/re2.node …

The verification has failed: building from sources …

Building locally …

/bin/sh: 1: npm: Permission denied

node: internal/process/promises:288

triggerUncaughtException(err, true /* fromPromise */);

^

[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason “127”.] {

code: ‘ERR_UNHANDLED_REJECTION’

}

Node.js v18.16.0

/bin/sh: 1: npm: Permission denied

yarn install v1.22.19

[1/5] Validating package.json…

[2/5] Resolving packages…

[3/5] Fetching packages…

[4/5] Linking dependencies…

[5/5] Building fresh packages…

Exit code: 127

Debug Information:

OS: Ubuntu, v20.04.6 LTS

Node Version: v18.16.0

Ghost Version: 5.47.0

Ghost-CLI Version: 1.24.0

Environment: production

Command: ‘ghost update --force’

Are there any special recommendations for having multiple ghost instances installed on the same server as far as NPM setup? Should each instance have its own NPM install? It is interesting that this has been working fine for a couple of years but a few months back, the upgrades are very unreliable, I always get errors like these OR permissions within the folders OR missing npm modules like chalk/luxon and others …

Any help is appreciated and please let me know if you need anyother details.

I have replaced the at signal with [AT] due to some limitations about tagging users.

Thank you,

-Marco

Ok, after some digging … I found out that someone changed the default umask value to 077 instead of 022 under /etc/login.defs … that resolved one of the issues which was the NPM folder under /usr/lib/node_modules having the wrong permissions …

However I still had some issues but I found out that this worked in all ghost installations 8 total, doing in order under each different domain:

sudo find ./ ! -path “./versions/*” -type f -exec chmod 664 {} ;
ghost update

edit config.production.json to remove bootstrap section, then I created a script to run all of these in order:

npm install luxon moment @stdlib/utils-copy chalk@4
sudo find . -name “.js" -exec chmod 755 {} ;
sudo find . -name "
.json” -exec chmod 755 {} ;
sudo find . -name “.cjs" -exec chmod 755 {} ;
sudo find . -name "
.hbs” -exec chmod 755 {} ;
sudo find ./ ! -path “./versions/*” -type f -exec chmod 664 {} ;

Then, finally ghost starts properly and updated:

So yes, still don’t get it why this is not working as it was before but at least this process works reliably …