Error when running cli update #5062

Closed
opened 2026-02-05 09:37:30 +03:00 by OVERLORD · 2 comments
Owner

Originally created by @lue30499 on GitHub (Nov 25, 2024).

Describe the Bug

Hello,

Updating from v24.10 to v24.10.2
Ubuntu 22.04.5 LTS
PHP 8.1.2-1ubuntu2.19

I run command:

cd /var/www/bookstack/
sudo -u www-data ./bookstack-system-cli update

I get the following:

WARNING: This CLI is in early alpha testing.
There's a high chance of running into bugs, and the CLI API is subject to change.

Checking system requirements...
Checking local Git repository is active...
Checking composer exists...
Fetching latest code via Git...
Installing PHP dependencies via composer...
Running database migrations...
PHP Notice:  include(): zlib: data error in phar:///var/www/bookstack/bookstack-system-cli/vendor/composer/ClassLoader.php on line 582
PHP Warning:  include(phar:///var/www/bookstack/bookstack-system-cli/vendor/composer/../../src/Services/ArtisanRunner.php): Failed to open stream: phar error: internal corruption of phar "/var/www/bookstack/bookstack-system-cli" (actual filesize mismatch on file "src/Services/ArtisanRunner.php") in phar:///var/www/bookstack/bookstack-system-cli/vendor/composer/ClassLoader.php on line 582
PHP Warning:  include(): Failed opening 'phar:///var/www/bookstack/bookstack-system-cli/vendor/composer/../../src/Services/ArtisanRunner.php' for inclusion (include_path='phar:///var/www/bookstack/bookstack-system-cli:.:/usr/share/php') in phar:///var/www/bookstack/bookstack-system-cli/vendor/composer/ClassLoader.php on line 582
PHP Fatal error:  Uncaught Error: Class "Cli\Services\ArtisanRunner" not found in phar:///var/www/bookstack/bookstack-system-cli/src/Commands/UpdateCommand.php:52
Stack trace:
#0 phar:///var/www/bookstack/bookstack-system-cli/vendor/symfony/console/Command/Command.php(291): Cli\Commands\UpdateCommand->execute()
#1 phar:///var/www/bookstack/bookstack-system-cli/vendor/symfony/console/Application.php(1014): Symfony\Component\Console\Command\Command->run()
#2 phar:///var/www/bookstack/bookstack-system-cli/vendor/symfony/console/Application.php(301): Symfony\Component\Console\Application->doRunCommand()
#3 phar:///var/www/bookstack/bookstack-system-cli/vendor/symfony/console/Application.php(171): Symfony\Component\Console\Application->doRun()
#4 phar:///var/www/bookstack/bookstack-system-cli/run.php(31): Symfony\Component\Console\Application->run()
#5 /var/www/bookstack/bookstack-system-cli(10): include('...')
#6 {main}
  thrown in phar:///var/www/bookstack/bookstack-system-cli/src/Commands/UpdateCommand.php on line 52

If I run the command again, I get:

WARNING: This CLI is in early alpha testing.
There's a high chance of running into bugs, and the CLI API is subject to change.

Checking system requirements...
Checking local Git repository is active...
Checking composer exists...
Fetching latest code via Git...
Installing PHP dependencies via composer...
Running database migrations...
Clearing app caches...
Your BookStack instance at [/var/www/bookstack] has been updated!

Not sure why I need to run the command twice...
It seems to be updated. The new version is reflected in the Settings page.

Regards,
Lue

Steps to Reproduce

At least for my system, which was installed a few years ago with the Ubuntu install script and kept up-to-date:

  1. cd /var/www/bookstack/
  2. sudo -u www-data ./bookstack-system-cli update
  3. Witness error
  4. sudo -u www-data ./bookstack-system-cli update
  5. Witness no error and successful upgrade.

Expected Behaviour

Run once to update

Screenshots or Additional Context

No response

Browser Details

Chrome 131.0.6778.86 (but don't believe to be a browser issue)

Exact BookStack Version

v24.10 to v24.10.2

Originally created by @lue30499 on GitHub (Nov 25, 2024). ### Describe the Bug Hello, Updating from v24.10 to v24.10.2 Ubuntu 22.04.5 LTS PHP 8.1.2-1ubuntu2.19 I run command: ``` cd /var/www/bookstack/ sudo -u www-data ./bookstack-system-cli update ``` I get the following: ``` WARNING: This CLI is in early alpha testing. There's a high chance of running into bugs, and the CLI API is subject to change. Checking system requirements... Checking local Git repository is active... Checking composer exists... Fetching latest code via Git... Installing PHP dependencies via composer... Running database migrations... PHP Notice: include(): zlib: data error in phar:///var/www/bookstack/bookstack-system-cli/vendor/composer/ClassLoader.php on line 582 PHP Warning: include(phar:///var/www/bookstack/bookstack-system-cli/vendor/composer/../../src/Services/ArtisanRunner.php): Failed to open stream: phar error: internal corruption of phar "/var/www/bookstack/bookstack-system-cli" (actual filesize mismatch on file "src/Services/ArtisanRunner.php") in phar:///var/www/bookstack/bookstack-system-cli/vendor/composer/ClassLoader.php on line 582 PHP Warning: include(): Failed opening 'phar:///var/www/bookstack/bookstack-system-cli/vendor/composer/../../src/Services/ArtisanRunner.php' for inclusion (include_path='phar:///var/www/bookstack/bookstack-system-cli:.:/usr/share/php') in phar:///var/www/bookstack/bookstack-system-cli/vendor/composer/ClassLoader.php on line 582 PHP Fatal error: Uncaught Error: Class "Cli\Services\ArtisanRunner" not found in phar:///var/www/bookstack/bookstack-system-cli/src/Commands/UpdateCommand.php:52 Stack trace: #0 phar:///var/www/bookstack/bookstack-system-cli/vendor/symfony/console/Command/Command.php(291): Cli\Commands\UpdateCommand->execute() #1 phar:///var/www/bookstack/bookstack-system-cli/vendor/symfony/console/Application.php(1014): Symfony\Component\Console\Command\Command->run() #2 phar:///var/www/bookstack/bookstack-system-cli/vendor/symfony/console/Application.php(301): Symfony\Component\Console\Application->doRunCommand() #3 phar:///var/www/bookstack/bookstack-system-cli/vendor/symfony/console/Application.php(171): Symfony\Component\Console\Application->doRun() #4 phar:///var/www/bookstack/bookstack-system-cli/run.php(31): Symfony\Component\Console\Application->run() #5 /var/www/bookstack/bookstack-system-cli(10): include('...') #6 {main} thrown in phar:///var/www/bookstack/bookstack-system-cli/src/Commands/UpdateCommand.php on line 52 ``` If I run the command again, I get: ``` WARNING: This CLI is in early alpha testing. There's a high chance of running into bugs, and the CLI API is subject to change. Checking system requirements... Checking local Git repository is active... Checking composer exists... Fetching latest code via Git... Installing PHP dependencies via composer... Running database migrations... Clearing app caches... Your BookStack instance at [/var/www/bookstack] has been updated! ``` Not sure why I need to run the command twice... It seems to be updated. The new version is reflected in the Settings page. Regards, Lue ### Steps to Reproduce At least for my system, which was installed a few years ago with the Ubuntu install script and kept up-to-date: 1. `cd /var/www/bookstack/` 2. `sudo -u www-data ./bookstack-system-cli update` 3. Witness error 4. `sudo -u www-data ./bookstack-system-cli update` 5. Witness no error and successful upgrade. ### Expected Behaviour Run once to update ### Screenshots or Additional Context _No response_ ### Browser Details Chrome 131.0.6778.86 (but don't believe to be a browser issue) ### Exact BookStack Version v24.10 to v24.10.2
OVERLORD added the 🐛 Bug label 2026-02-05 09:37:30 +03:00
Author
Owner

@ssddanbrown commented on GitHub (Nov 25, 2024):

Thanks @lue30499 for reporting,
Another user has also mentioned the same issue, including the successful re-run.

I did update the system CLI in v24.10.1.
Without digging into testing myself, My guess is that this is due to the system CLI itself being changed as part of the update process, while running.

Might be a tricky one to address.
Potentially the CLI could copy itself out to a different location before running itself in this scenario? Might have further complications in practice.

@ssddanbrown commented on GitHub (Nov 25, 2024): Thanks @lue30499 for reporting, Another user has also mentioned the same issue, including the successful re-run. I did update the system CLI in v24.10.1. Without digging into testing myself, My guess is that this is due to the system CLI itself being changed as part of the update process, while running. Might be a tricky one to address. Potentially the CLI could copy itself out to a different location before running itself in this scenario? Might have further complications in practice.
Author
Owner

@ssddanbrown commented on GitHub (Mar 12, 2025):

I've made some improvements to this as part of the changes in https://codeberg.org/bookstack/system-cli/pulls/21.

The CLI will now detect changes to the CLI during the update process, and exit early, telling the user to re-run the command to complete the update process.
A little awkward, but keeps implementation simple while preventing an outright confusing error.

Will be part of the next patch release, although you will still experience this if upgrading to v25.02.1 (or above) from an older version since that'd still be using the old CLI.

@ssddanbrown commented on GitHub (Mar 12, 2025): I've made some improvements to this as part of the changes in https://codeberg.org/bookstack/system-cli/pulls/21. The CLI will now detect changes to the CLI during the update process, and exit early, telling the user to re-run the command to complete the update process. A little awkward, but keeps implementation simple while preventing an outright confusing error. Will be part of the next patch release, although you will still experience this if upgrading to v25.02.1 (or above) from an older version since that'd still be using the old CLI.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#5062