Ghost CLI installs wrong minor version

Ghost CLI commands `update`/`install` misinterprets provided versions, if omitting patch version, 2 digits & ending in 0

Ghost CLI installs wrong minor version


The Ghost CLI allows for updating (and installing) specific versions/tags of Ghost. It is possible to provide them with v as a prefix, or without, as well as only providing the major version or the major and minor versions, omitting the patch version.
If the minor version is a multiple of 10 (10, 20, ...), having at least 2 digits and ending in 0, the wrong version gets installed. The 2 digits are split, and the first is used as the minor version and the 0 as the patch version.

Steps to Reproduce

  1. Have a Ghost install
    Preferably, with version <5.20, so the --force flag doesn't need to be used

  2. Run ghost update and provide a specific version, that has a minor version of a multiple of 10 and don't provide the patch version, like ghost update 5.20

  3. Observe, that Ghost version 5.2.0 is getting installed

CLI command ghost update 5.20 log:

$ ghost update 5.20

Love open source? We’re hiring JavaScript Engineers to work on Ghost full-time.

Running in development mode

✔ Checking system Node.js version - found v16.18.1
✔ Ensuring user is not logged in as ghost user
✔ Checking if logged in user is directory owner
✔ Checking current folder permissions
✔ Checking memory availability
✔ Checking free space
✔ Checking for available migrations
✔ Checking for latest Ghost version
✔ Release notes were not found
✔ Downloading and updating Ghost to v5.2.0
✔ Linking latest Ghost and recording versions
✔ Removing old Ghost versions
ghost update 5.20  15.27s user 9.01s system 137% cpu 17.708 total
Like with ghost update 5.21, it should install the correct minor version. Preferably, with the current patch version.

GitHub issue:

Workarounds, tips and hints

Specify the full version including the patch version, like: ghost update v5.22.10

Did you find this article valuable?

Support writings by becoming a sponsor. Any amount is appreciated!