Prompts have been disabled when trying to update ghost using cron

If you’re looking for help, please provide information about your environment. If you delete this template and don’t provide any information, your topic will be automatically closed.

If you aren’t running the latest version of Ghost, the first thing we’ll ask you to do is update to the latest version of Ghost.

  • What’s your URL? This is the easiest way for others to help you
    blog.talescript.com
  • What version of Ghost are you using? If it’s not the latest, please update Ghost first before opening your topic
ghost version

Ghost-CLI version: 1.25.3
Ghost version: 5.75.1 (at /var/www/talescript)

And

node --version
v18.17.1
cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04.6 LTS (Focal Fossa)"
mysql --version
mysql  Ver 8.0.35-0ubuntu0.20.04.1 for Linux on x86_64 ((Ubuntu))
Firefox
  • What errors or information do you see in the console?
cat ghost_error.log 

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

- Inspecting operating system
- Checking for deprecations

[13:25:03] Checking for Ghost-CLI updates [started]
[13:25:03] Checking for Ghost-CLI updates [completed]
[13:25:03] Ensuring correct ~/.config folder ownership [started]
[13:25:03] Ensuring correct ~/.config folder ownership [completed]

+ sudo systemctl is-active ghost_blog-talescript-com
/usr/lib/node_modules/ghost-cli/lib/ui/index.js:148
            throw new errors.SystemError('Prompts have been disabled, all options must be provided via command line flags');
            ^

SystemError: Prompts have been disabled, all options must be provided via command line flags
    at UI.prompt (/usr/lib/node_modules/ghost-cli/lib/ui/index.js:148:19)
    at Socket.<anonymous> (/usr/lib/node_modules/ghost-cli/lib/ui/index.js:248:22)
    at Socket.emit (node:events:526:35)
    at addChunk (node:internal/streams/readable:324:12)
    at readableAddChunk (node:internal/streams/readable:297:9)
    at Readable.push (node:internal/streams/readable:234:10)
    at Pipe.onStreamRead (node:internal/stream_base_commons:190:23) {
  options: {
    message: 'Prompts have been disabled, all options must be provided via command line flags'
  },
  logMessageOnly: undefined,
  help: 'You can always refer to https://ghost.org/docs/ghost-cli/ for troubleshooting.',
  err: {}
}

Node.js v18.17.1
  • What steps could someone else take to reproduce the issue you’re having?

I have a bash script to update ghost.

#!/usr/bin/bash

DIR=/var/www

sudo -u ghostUser bash << EOF
    cd $DIR/talescript && ghost update && \
    cd $DIR/johnswebsite && ghost update
EOF

as an aside, I’m not too sure if using sudo in the script is a good practice or not

I’ve added a nopasswd into visudo

ghostUser ALL=(ghostUser) NOPASSWD: /home/ghostUser/bin/update_ghost.sh

The cronjob was created using root sudo crontab -e

25 13 * * * /usr/bin/bash /home/ghostUser/bin/update_ghost.sh >> /home/ghostUser/bin/ghost_error.log 2>&1

After an extensive search, this is the closest workable suggestion I have managed to find but I am not entirely sure if it is the correct solution [Using Ghost-CLI programatically · Issue #721 · TryGhost/Ghost-CLI · GitHub](https://Using Ghost-CLI programatically) (honestly I didn’t quite understand the proposed solution)

**EDIT:**So, I changed from using the root crontab to using the users crontab crontab -e and managed to get rid of the errors, however, it is not updating to the new version of ghost

cat ghost_error.log

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

- Inspecting operating system
- Checking for deprecations

[15:19:05] Checking for Ghost-CLI updates [started]
[15:19:05] Checking for Ghost-CLI updates [completed]
[15:19:05] Ensuring correct ~/.config folder ownership [started]
[15:19:05] Ensuring correct ~/.config folder ownership [completed]

+ sudo systemctl is-active ghost_blog-talescript-com

I’m not sure exactly what’s going wrong, but it appears related to sudo. The system is trying to prompt for password. I’ll suggest a more modern, alternate solution using systemd timers and services.

In this design, we’ll create a systemd service and timer to update each update. Systemd will handle collecting the logs for each in their own “unit”, so you can look at the logs for each build individually.

This design still requires that sudo will be used, but this time to run ghost update, so first, I’d update your sudoers file:

sudoers file

ghostUser ALL=(ghostUser) NOPASSWD: ghost update

Then let’s create the first system service file, named /etc/systemd/system/ghost-update-talescript.service

systemd service file

[Unit]
Description=Update TaleScript Ghost Instance

[Service]
User=ghostUser
WorkingDirectory=/var/www/talescript
ExecStart=ghost update

Next, create a timer unit named /etc/systemd/system/ghost-update-talescript.timer to start it:

systemd unit file

[Unit]
Description=Timer for Ghost TaleScript Update

[Timer]
OnCalendar= *-*-* 13:00:00

[Install]
WantedBy=timers.target

Tell systemd you’ve added some files

sudo systemctl daemon-reload

Test and view the logs

Try running the updater and viewing the logs. You may wish to use two different terminals for this, as the updater may appear to hang while it’s running

# In first terminal
sudo systemctl start ghost-update-talescript

# In a second terminal, which the progress
journalctl -fu ghost-update-talescript

Enable the timer

Finally, set your timer to start at boot and start running immediately:

sudo systemctl enable --now ghost-update-talescript.timer

If everything works, you can create a second service unit and timer user offset by a half an hour or an hour to run the second one.

Finding the logs

You’ll be able to find the logs for the runs under their unit names

journalctl -eu ghost-update-talescript
journalctl -eu ghost-update-johnswebsite

Thank you for the reply. I’m getting the same error but at least the logs are readable :slight_smile:

  • Prompts have been disabled
  • sudo auth
journalctl -eu ghost-update-talescript
Hint: You are currently not seeing messages from other users and the system.
      Users in groups 'adm', 'systemd-journal' can see all messages.
      Pass -q to turn off this notice.
Dec 14 16:28:11 ubuntu-ghost-blog ghost[2091383]:     at Readable.push (node:internal/streams/readable:234:10)
Dec 14 16:28:11 ubuntu-ghost-blog ghost[2091383]:     at Pipe.onStreamRead (node:internal/stream_base_commons:190:23) {
Dec 14 16:28:11 ubuntu-ghost-blog ghost[2091383]:   options: {
Dec 14 16:28:11 ubuntu-ghost-blog ghost[2091383]:     message: 'Prompts have been disabled, all options must be provided via command line fla>
Dec 14 16:28:11 ubuntu-ghost-blog ghost[2091383]:   },
Dec 14 16:28:11 ubuntu-ghost-blog ghost[2091383]:   logMessageOnly: undefined,
Dec 14 16:28:11 ubuntu-ghost-blog ghost[2091383]:   help: 'You can always refer to https://ghost.org/docs/ghost-cli/ for troubleshooting.',
Dec 14 16:28:11 ubuntu-ghost-blog ghost[2091383]:   err: {}
Dec 14 16:28:11 ubuntu-ghost-blog ghost[2091383]: }
Dec 14 16:28:11 ubuntu-ghost-blog ghost[2091383]: Node.js v18.17.1
Dec 14 16:28:11 ubuntu-ghost-blog sudo[2091420]: pam_unix(sudo:auth): conversation failed
Dec 14 16:28:11 ubuntu-ghost-blog sudo[2091420]: pam_unix(sudo:auth): auth could not identify password for [ghostUser]

in visudo I did get some issues when I was trying to save the file. The only way I was able to get around the checker complaining, was adding the full path for ghost, instead of using just ghost update

ghostUser ALL=(ghostUser) NOPASSWD: /home/ghostUser/.npm-global/bin/ghost update

I don’t get what the issue is. When I run the script, it works. When I was running it with Cron I kinda figured the issue was that I had used root cron, which runs the commands as root instead of the ghostUser. Once I changed to running the script through the users cron, the script kinda ran but still had issues (the logs I was saving to a file were not that useful).

With the current issue on sytemd (which seems to be the same as with cron)

  • Prompts have been disabled
  • sudo auth

Just as a sanity check, I don’t need to restart the shell after making changes to the sudoers file, do I now?

EDIT: I’ve changed the ownership for the new services to the user (I don’t know if that makes a difference), but still getting kinda the same errors, but seems like it progresses and then fails when trying to update

Dec 14 18:09:24 ubuntu-ghost-blog ghost[2093936]: - Inspecting operating system
Dec 14 18:09:24 ubuntu-ghost-blog ghost[2093936]: - Checking for deprecations
Dec 14 18:09:24 ubuntu-ghost-blog ghost[2093936]: [18:09:24] Checking for Ghost-CLI updates [started]
Dec 14 18:09:25 ubuntu-ghost-blog ghost[2093936]: [18:09:25] Checking for Ghost-CLI updates [completed]
Dec 14 18:09:25 ubuntu-ghost-blog ghost[2093936]: [18:09:25] Ensuring correct ~/.config folder ownership [started]
Dec 14 18:09:25 ubuntu-ghost-blog ghost[2093936]: [18:09:25] Ensuring correct ~/.config folder ownership [completed]
Dec 14 18:09:25 ubuntu-ghost-blog ghost[2093936]: + sudo systemctl is-active ghost_blog-talescript-com
Dec 14 18:09:25 ubuntu-ghost-blog ghost[2093936]: /home/ghostUser/.npm-global/lib/node_modules/ghost-cli/lib/ui/index.js:148
Dec 14 18:09:25 ubuntu-ghost-blog ghost[2093936]:             throw new errors.SystemError('Prompts have been disabled, all options must be provided via command line flags');
.......
Dec 14 18:09:25 ubuntu-ghost-blog sudo[2093975]: pam_unix(sudo:auth): conversation failed
Dec 14 18:09:25 ubuntu-ghost-blog sudo[2093975]: pam_unix(sudo:auth): auth could not identify password for [ghostUser]

Were you able to make progress on this or are you still stuck?