Ghost-CLI icon indicating copy to clipboard operation
Ghost-CLI copied to clipboard

Error message when checking the presence of the "ghost" user is imprecise

Open tmlmt opened this issue 1 year ago • 0 comments

Steps to Reproduce

  1. Initiate a ghost instance without systemd unit setup
  2. Change the ownership of the folder and subfolders to simulate wrong ownership
  3. Execute ghost setup systemd

Output

myuser@mymachine:/var/www/tmlmt/blog$ ghost setup systemd

Love open source? We’re hiring JavaScript Engineers to work on Ghost full-time.
https://careers.ghost.org



The "ghost" user has not been created, try running `ghost setup linux-user` first
ℹ Setting up Systemd [skipped]

Expected behavior

I would expect the systemd step to be executed, not skipped

Analysis

The systemd step checks whether the ghost user exists using the getUid function and checking whether the return value evaluates as false https://github.com/TryGhost/Ghost-CLI/blob/79bfa4744408a6400e9df9fc37d0597c26c9cd4e/extensions/systemd/index.js#L38-L43

But that function actually does two things: it returns the uid of the ghost user when it exists, or if returns null if the directory is not owned by that user.

https://github.com/TryGhost/Ghost-CLI/blob/79bfa4744408a6400e9df9fc37d0597c26c9cd4e/extensions/systemd/get-uid.js#L13-L21

The logic above should probably be changed either to explicitely separate the two distinct checks that are made, so that, in case the directory's ownership is not correct, the message error doesn't refer to the ghost user not existing, when it does.

Technical details

This is automatically output by Ghost-CLI if an error occurs, please copy & paste:

  • OS: Ubuntu 24.04
  • Node Version: 18.20.4
  • Ghost-CLI Version: 1.26.1
  • Environment: bash
  • Command: ghost setup systemd

Bug submission checklist

Please fill out this checklist to acknowledge that you followed the requirements to submit a bug report.

  • [x] Tried to find help in the forum & docs
  • [x] Checked for existing issues
  • [x] Attached log file
  • [x] Provided technical details incl. operating system

tmlmt avatar Aug 04 '24 07:08 tmlmt