Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
4 tasks done
tmlmt opened this issue Aug 4, 2024 · 0 comments
Open
4 tasks done

Comments

@tmlmt
Copy link

tmlmt commented Aug 4, 2024

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

const uid = getUid(instance.dir);
// getUid returns either the uid or null
if (!uid) {
return task.skip('The "ghost" user has not been created, try running `ghost setup linux-user` first');
}

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.

module.exports = function getUid(dir) {
try {
const uid = execa.shellSync('id -u ghost').stdout;
const stat = fs.lstatSync(path.join(dir, 'content'));
if (stat.uid.toString() !== uid) {
// Ghost user is not the owner of this folder, return null
return null;
}

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.

  • Tried to find help in the forum & docs
  • Checked for existing issues
  • Attached log file
  • Provided technical details incl. operating system
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant