Unable to upgrade Ghost from v3.16.1 to v3.18.0

Hi Everyone,

I’ve tried to update my ghost blog (v3.16.1 + Sqlite3) to the last release (3.18.0) but it failed.
Furthermore ghost-cli seems to be unable to rollback :thinking:

  • Any idea of what’s happened ?

STEPS

  • sudo npm install -g ghost-cli@latest
  • ghost update
? Unable to upgrade Ghost from v3.16.1 to v3.18.0. Would you like to revert back to v3.16.1? Yes
+ sudo systemctl is-active ghost_mydomain-com
+ sudo systemctl reset-failed ghost_mydomain-com
✔ Checking system Node.js version
✔ Ensuring user is not logged in as ghost user
✔ Checking if logged in user is directory owner
✔ Checking current folder permissions
✔ Checking folder permissions
✔ Checking file permissions
✔ Checking content folder ownership
✔ Checking for available migrations
✔ Checking for latest Ghost version
ℹ Downloading and updating Ghost [skipped]
+ sudo /srv//mydomaincom/current/node_modules/.bin/knex-migrator-rollback --force --v 3.16.1 --mgpath /srv//mydomaincom/current
✖ Rolling back database migrations
A ProcessError occurred.

Message: The database migration in Ghost encountered an error.
Help: https://ghost.org/faq/upgrade-to-ghost-2-0/#what-to-do-when-an-upgrade-fails
Suggestion: ghost update --rollback
Debug Information:
    OS: Ubuntu, v18.04.4 LTS
    Node Version: v12.17.0
    Ghost Version: 3.18.0
    Ghost-CLI Version: 1.14.0
    Environment: production
    Command: 'ghost update'
Message: SQLITE_CANTOPEN: unable to open database file
Help: Unknown database error
Suggestion: journalctl -u ghost_mydomain-com -n 50
Stack: Error: SQLITE_CANTOPEN: unable to open database file
    at Server.<anonymous> (/usr/lib/node_modules/ghost-cli/lib/utils/port-polling.js:38:28)
    at Object.onceWrapper (events.js:421:28)
    at Server.emit (events.js:315:20)
    at emitCloseNT (net.js:1655:8)
    at processTicksAndRejections (internal/process/task_queues.js:83:21)

Run “Ghost Start”

+ sudo systemctl is-active ghost_mydomaincom
✔ Ensuring user is not logged in as ghost user
✔ Checking if logged in user is directory owner
✔ Checking current folder permissions
+ sudo systemctl is-active ghost_mydomaincom
✔ Validating config
✔ Checking folder permissions
✔ Checking file permissions
✔ Checking content folder ownership
✔ Checking memory availability
✔ Checking binary dependencies
+ sudo systemctl start ghost_mydomaincom
+ sudo systemctl stop ghost_mydomaincom
✖ Starting Ghost: mydomaincom
A GhostError occurred.

Message: SQLITE_CANTOPEN: unable to open database file
Help: Unknown database error
Suggestion: journalctl -u ghost_mydomaincom -n 50

Debug Information:
    OS: Ubuntu, v18.04.4 LTS
    Node Version: v12.17.0
    Ghost Version: 3.18.0
    Ghost-CLI Version: 1.14.0
    Environment: production
    Command: 'ghost start'

Debug log

Debug Information:
    OS: Ubuntu, v18.04.4 LTS
    Node Version: v12.17.0
    Ghost Version: 3.18.0
    Ghost-CLI Version: 1.14.0
    Environment: production
    Command: 'ghost start'
Message: SQLITE_CANTOPEN: unable to open database file
Help: Unknown database error
Suggestion: journalctl -u ghost_mydomaincom -n 50
Stack: Error: SQLITE_CANTOPEN: unable to open database file
    at Server.<anonymous> (/usr/lib/node_modules/ghost-cli/lib/utils/port-polling.js:38:28)
    at Object.onceWrapper (events.js:421:28)
    at Server.emit (events.js:315:20)
    at emitCloseNT (net.js:1655:8)
    at processTicksAndRejections (internal/process/task_queues.js:83:21)

Thank you in advance !

We just fixed this in 3.18.1 so please update using Ghost-CLI :slightly_smiling_face:

Hi @Hannah

I did it but it failed :frowning_face:

What should I do ?

npm install -g ghost-cli@latest
/usr/bin/ghost -> /usr/lib/node_modules/ghost-cli/bin/ghost
+ ghost-cli@1.14.0
updated 1 package in 12.047s
sudo npm install -g npm
/usr/bin/npm -> /usr/lib/node_modules/npm/bin/npm-cli.js
/usr/bin/npx -> /usr/lib/node_modules/npm/bin/npx-cli.js
+ npm@6.14.5
updated 5 packages in 15.417s
ghost update
+ sudo systemctl is-active ghost_mydomaincom
✔ Checking system Node.js version
✔ Ensuring user is not logged in as ghost user
✔ Checking if logged in user is directory owner
✔ Checking current folder permissions
✔ Checking folder permissions
✔ Checking file permissions
✔ Checking content folder ownership
✔ Checking memory availability
✔ Checking for available migrations
✔ Checking for latest Ghost version
✔ Downloading and updating Ghost to v3.18.1
+ sudo systemctl stop ghost_mydomaincom
✔ Stopping Ghost
✔ Linking latest Ghost and recording versions
+ sudo systemctl start ghost_mydomaincom
+ sudo systemctl stop ghost_mydomaincom
✖ Restarting Ghost
A GhostError occurred.

Message: SQLITE_CANTOPEN: unable to open database file
Help: Unknown database error
Suggestion: journalctl -u ghost_mydomaincom -n 50

Debug Information:
    OS: Ubuntu, v18.04.4 LTS
    Node Version: v12.17.0
    Ghost Version: 3.18.1
    Ghost-CLI Version: 1.14.0
    Environment: production
    Command: 'ghost update'

Debug log

Debug Information:
    OS: Ubuntu, v18.04.4 LTS
    Node Version: v12.17.0
    Ghost Version: 3.18.1
    Ghost-CLI Version: 1.14.0
    Environment: production
    Command: 'ghost update'
Message: SQLITE_CANTOPEN: unable to open database file
Help: Unknown database error
Suggestion: journalctl -u ghost_mydomaincom -n 50
Stack: Error: SQLITE_CANTOPEN: unable to open database file
    at Server.<anonymous> (/usr/lib/node_modules/ghost-cli/lib/utils/port-polling.js:38:28)
    at Object.onceWrapper (events.js:421:28)
    at Server.emit (events.js:315:20)
    at emitCloseNT (net.js:1655:8)
    at processTicksAndRejections (internal/process/task_queues.js:83:21)

Thank you for your help !

Sorry I saw the 3.18 and the line saying “Message: The database migration in Ghost encountered an error.” and assumed it was the bug we just fixed.

Scrolling down further I see

SQLITE_CANTOPEN: unable to open database file

Which is pretty clear about what’s happening, just not giving a reason why.

Only thing I can see that might be a clue is the double slash in your path here - maybe that’s preventing the file from being readable/opened by sqlite?

Hi,

Sorry he double slash in the path is a copy/past error !

Yes it’s weird, error is clear but not verbose and I can’t rollback to release 3.16.1
I’m cursed with updates :see_no_evil: :sweat_smile:

ghost update --rollback
+ sudo systemctl is-active ghost_mydomaincom
✔ Checking system Node.js version
✔ Ensuring user is not logged in as ghost user
✔ Checking if logged in user is directory owner
✔ Checking current folder permissions
✔ Checking folder permissions
✔ Checking file permissions
✔ Checking content folder ownership
✔ Checking memory availability
✔ Checking for available migrations
✔ Checking for latest Ghost version
ℹ Downloading and updating Ghost [skipped]
+ sudo /srv/mydomaincom/current/node_modules/.bin/knex-migrator-rollback --force --v 3.18.0 --mgpath /srv/mydomaincom/current
✖ Rolling back database migrations
A ProcessError occurred.

Message: The database migration in Ghost encountered an error.
Help: https://ghost.org/faq/upgrade-to-ghost-2-0/#what-to-do-when-an-upgrade-fails
Suggestion: ghost update --rollback

Debug

Debug Information:
    OS: Ubuntu, v18.04.4 LTS
    Node Version: v12.17.0
    Ghost Version: 3.18.1
    Ghost-CLI Version: 1.14.0
    Environment: production
    Command: 'ghost update --rollback'
Message: The database migration in Ghost encountered an error.
Help: https://ghost.org/faq/upgrade-to-ghost-2-0/#what-to-do-when-an-upgrade-fails
Suggestion: ghost update --rollback
--------------- stderr ---------------
[2020-06-02 19:07:32] ERROR SQLITE_CANTOPEN: unable to open database file
ghost doctor
✔ Checking system Node.js version
✔ Checking logged in user
✔ Ensuring user is not logged in as ghost user
✔ Checking if logged in user is directory owner
✔ Checking current folder permissions
✔ Checking operating system compatibility
+ sudo systemctl is-active ghost_mydomain-com
? Sudo Password [hidden]
✔ Validating config
✔ Checking folder permissions
✔ Checking file permissions
✔ Checking content folder ownership
✔ Checking memory availability
✔ Checking binary dependencies

Hi @Hannah

I found the issue !
To solve it I have to set the absolute path on the database path in the “config.production.json” file.

Before

  "database": {
    "client": "sqlite3",
    "connection": {
      "filename": "./content/data/ghost.db"
    }

Now

  "database": {
    "client": "sqlite3",
    "connection": {
      "filename": "/srv/mydomaincom/content/data/ghost.db"
    }

Then run ghost start

1 Like

Many thanks, Whys, you just saved my evening ! Your solution just work perfectly !

1 Like

Hi Ghost Team,

I’ve updated another ghost blog instance and faced the same issue so I decided to do a fresh install to understand the problem. :thinking:
It seems that there is a “bug/regression” when installing Ghost + Sqlite3, you need to specify the absolute “Database path” post install in the config.production.json.

I hope this help !
Whys

1 Like

Hey @Whys, thanks for the feedback! There was an edge-case in the Ghost CLI which has been fixed, but not yet released :slight_smile:

1 Like

Ghost CLI v1.14.1 has been released which fixes this issue :smiley:

Hi,

Yes I’ve tested it, thank you !