snipe / snipe-it

A free open source IT asset/license management system
https://snipeitapp.com
GNU Affero General Public License v3.0
11.12k stars 3.19k forks source link

Upgrade 5.2 to latest failed #11466

Closed astrugatch closed 2 years ago

astrugatch commented 2 years ago

Debug mode

Describe the bug

Running upgrade.php Getting the following in multiple sections.

In ProviderRepository.php line 208:

  Class 'Barryvdh\DomPDF\ServiceProvider' not found

Reproduction steps

Running Ubuntu 20.04 checked to make sure I have all the correct PHP extensions ran a self upgrade on composer, chown & chmod 755 on snipeit folder for www-data to fix permission error. Running upgrade.php as www-data Did git fetch --all & git reset --hard origin/master

Expected behavior

Expect to run through the upgrade process without errors. This is definitely self inflicted, I just don't see what I'm missing.

--------------------------------------------------------
WELCOME TO THE SNIPE-IT UPGRADER!
--------------------------------------------------------

This script will attempt to:

- validate some very basic .env file settings
- check your PHP version and extension requirements
- check directory permissions
- do a git pull to bring you to the latest version
- run composer install to get your vendors up to date
- run migrations to get your schema up to date
- clear out old cache settings

--------------------------------------------------------
STEP 1: Checking .env file:
- Your .env is located at /var/www/html/snipe-it/snipe-it/.env
--------------------------------------------------------

√ Your APP_KEY is not blank.
√ Your APP_URL is not null or blank. It is set to https://snipeit.spfk12.org
√ Your APP_URL is set to https://snipeit.spfk12.org and starts with the protocol (https:// or http://)
√ Your APP_URL (https://snipeit.spfk12.org) does not have a trailing slash.

--------------------------------------------------------
STEP 2: Checking PHP requirements:
--------------------------------------------------------

Current PHP version: (7.4.3) is at least 7.4.0 - continuing...
FYI: The php.ini used by this PHP is: /etc/php/7.4/cli/php.ini

Checking Required PHP extensions...

√ bcmath is installed!
√ curl is installed!
√ fileinfo is installed!
√ gd is installed!
√ json is installed!
√ ldap is installed!
√ mbstring is installed!
√ mysqli is installed!
√ openssl is installed!
√ PDO is installed!
√ sodium is installed!
√ tokenizer is installed!
√ xml is installed!
√ zip is installed!

--------------------------------------------------------
STEP 3: Checking directory permissions:
--------------------------------------------------------

√ /var/www/html/snipe-it/snipe-it/bootstrap/cache is writable
√ /var/www/html/snipe-it/snipe-it/storage is writable
√ /var/www/html/snipe-it/snipe-it/storage/logs is writable
√ /var/www/html/snipe-it/snipe-it/storage/logs/laravel.log is writable
√ /var/www/html/snipe-it/snipe-it/storage/framework is writable
√ /var/www/html/snipe-it/snipe-it/storage/framework/cache is writable
√ /var/www/html/snipe-it/snipe-it/storage/framework/sessions is writable
√ /var/www/html/snipe-it/snipe-it/storage/framework/views is writable
√ /var/www/html/snipe-it/snipe-it/storage/app is writable
√ /var/www/html/snipe-it/snipe-it/storage/app/backups is writable
√ /var/www/html/snipe-it/snipe-it/storage/app/backup-temp is writable
√ /var/www/html/snipe-it/snipe-it/storage/private_uploads is writable
√ /var/www/html/snipe-it/snipe-it/public/uploads is writable

--------------------------------------------------------
STEP 4: Backing up database:
--------------------------------------------------------

--
In ProviderRepository.php line 208:

  Class 'Barryvdh\DomPDF\ServiceProvider' not found

--------------------------------------------------------
STEP 5: Putting application into maintenance mode:
--------------------------------------------------------

--
In ProviderRepository.php line 208:

  Class 'Barryvdh\DomPDF\ServiceProvider' not found

--------------------------------------------------------
STEP 6: Pulling latest from Git (master branch):
--------------------------------------------------------

Git is installed.
Already on 'master'
-- No local changes to save
-- Your branch is up to date with 'origin/master'.
-- Already up to date.

--------------------------------------------------------
STEP 7: Cleaning up old cached files:
--------------------------------------------------------

√ No bootstrap/cache/compiled.php, so nothing to delete.
√ No bootstrap/cache/services.php, so nothing to delete.
√ No bootstrap/cache/config.php, so nothing to delete.
√ No vendor/symfony/translation/TranslatorInterface.php, so nothing to delete.

--
In ProviderRepository.php line 208:

  Class 'Barryvdh\DomPDF\ServiceProvider' not found

--
In ProviderRepository.php line 208:

  Class 'Barryvdh\DomPDF\ServiceProvider' not found

--
In ProviderRepository.php line 208:

  Class 'Barryvdh\DomPDF\ServiceProvider' not found

--
In ProviderRepository.php line 208:

  Class 'Barryvdh\DomPDF\ServiceProvider' not found

--------------------------------------------------------
STEP 8: Updating composer dependencies:
(This may take a moment.)
--------------------------------------------------------

-- Running the app in production mode.
-- We couldn't find a local composer.phar. No worries, trying globally.
Since you are running composer globally, we won't try to update it for you.
If you run into issues with this step, try running `composer self-update`
before running this updater again

Installing dependencies from lock file
Verifying lock file contents can be installed on current platform.
Package operations: 44 installs, 96 updates, 10 removals
  - Syncing symfony/deprecation-contracts (v2.5.1) into cache
Cloning failed using an ssh key for authentication, enter your GitHub credentials to access private repos
When working with _public_ GitHub repositories only, head to https://github.com/settings/tokens/new?scopes=&description=Composer+on+snipeit+2022-07-05+0954 to retrieve a token.
This token will have read-only permission for public information only.
When you need to access _private_ GitHub repositories as well, go to https://github.com/settings/tokens/new?scopes=repo&description=Composer+on+snipeit+2022-07-05+0954
Note that such tokens have broad read/write permissions on your behalf, even if not needed by Composer.
Tokens will be stored in plain text in "/var/www/.config/composer/auth.json" for future use by Composer.
For additional information, check https://getcomposer.org/doc/articles/authentication-for-private-packages.md#github-oauth
Token (hidden):

Screenshots

No response

Snipe-IT Version

5.2

Operating System

Ubuntu

Web Server

Apache

PHP Version

7.4

Operating System

No response

Browser

No response

Version

No response

Device

No response

Operating System

No response

Browser

No response

Version

No response

Error messages

No response

Additional context

I don't remember what process was originally used for the install. It was a ways back.

mikeroq commented 2 years ago

Try running composer self-update --2 and try upgrade again. I don't know if you are already on composer 2 or not.

astrugatch commented 2 years ago
Storing "stable" as default update channel for the next self-update run.
You are already using the latest available Composer version 2.3.8 (2.x channel).
mikeroq commented 2 years ago

Try composer update on it's own.

astrugatch commented 2 years ago

When I try to re-reun composer install I get:

file_put_contents(/var/www/.config/composer/auth.json): failed to open stream: No such file or directory

astrugatch commented 2 years ago

Composer update gets:

snipeadmin@snipeit:/var/www/html/snipe-it/snipe-it$ composer update
Loading composer repositories with package information
Info from https://repo.packagist.org: #StandWithUkraine
Updating dependencies
Lock file operations: 0 installs, 57 updates, 0 removals
  - Upgrading aws/aws-sdk-php (3.222.13 => 3.229.2)
  - Upgrading barryvdh/laravel-debugbar (v3.6.7 => v3.6.8)
  - Upgrading barryvdh/laravel-dompdf (v1.0.0 => v1.0.2)
  - Upgrading doctrine/annotations (1.13.2 => 1.13.3)
  - Upgrading doctrine/cache (1.12.1 => 1.13.0)
  - Upgrading doctrine/dbal (3.3.6 => 3.3.7)
  - Upgrading doctrine/reflection (1.2.2 => 1.2.3)
  - Upgrading facade/ignition (2.17.5 => 2.17.6)
  - Upgrading guzzlehttp/guzzle (7.4.2 => 7.4.5)
  - Upgrading guzzlehttp/psr7 (2.2.1 => 2.4.0)
  - Upgrading intervention/image (2.7.1 => 2.7.2)
  - Upgrading laravel/framework (v8.83.12 => v8.83.18)
  - Upgrading laravel/serializable-closure (v1.1.1 => v1.2.0)
  - Upgrading laravel/ui (v3.4.5 => v3.4.6)
  - Upgrading league/commonmark (2.3.1 => 2.3.3)
  - Upgrading league/flysystem-aws-s3-v3 (1.0.29 => 1.0.30)
  - Upgrading league/uri (6.5.0 => 6.7.1)
  - Upgrading livewire/livewire (v2.10.5 => v2.10.6)
  - Upgrading maennchen/zipstream-php (2.1.0 => 2.2.1)
  - Upgrading monolog/monolog (2.6.0 => 2.7.0)
  - Upgrading nesbot/carbon (2.58.0 => 2.59.1)
  - Upgrading nikic/php-parser (v4.13.2 => v4.14.0)
  - Upgrading nyholm/psr7 (1.5.0 => 1.5.1)
  - Upgrading overtrue/phplint (3.0.6 => 3.1.1)
  - Upgrading paragonie/constant_time_encoding (v2.5.0 => v2.6.3)
  - Upgrading phpunit/phpunit (9.5.20 => 9.5.21)
  - Upgrading pragmarx/google2fa (8.0.0 => v8.0.1)
  - Upgrading psy/psysh (v0.11.4 => v0.11.6)
  - Upgrading squizlabs/php_codesniffer (3.6.2 => 3.7.1)
  - Upgrading symfony/console (v5.4.8 => v5.4.10)
  - Upgrading symfony/deprecation-contracts (v2.5.1 => v2.5.2)
  - Upgrading symfony/dom-crawler (v4.4.39 => v4.4.42)
  - Upgrading symfony/error-handler (v5.4.8 => v5.4.9)
  - Upgrading symfony/event-dispatcher (v5.4.3 => v5.4.9)
  - Upgrading symfony/event-dispatcher-contracts (v2.5.1 => v2.5.2)
  - Upgrading symfony/http-foundation (v5.4.8 => v5.4.10)
  - Upgrading symfony/http-kernel (v5.4.8 => v5.4.10)
  - Upgrading symfony/mime (v5.4.8 => v5.4.10)
  - Upgrading symfony/polyfill-ctype (v1.25.0 => v1.26.0)
  - Upgrading symfony/polyfill-iconv (v1.25.0 => v1.26.0)
  - Upgrading symfony/polyfill-intl-grapheme (v1.25.0 => v1.26.0)
  - Upgrading symfony/polyfill-intl-idn (v1.25.0 => v1.26.0)
  - Upgrading symfony/polyfill-intl-normalizer (v1.25.0 => v1.26.0)
  - Upgrading symfony/polyfill-mbstring (v1.25.0 => v1.26.0)
  - Upgrading symfony/polyfill-php72 (v1.25.0 => v1.26.0)
  - Upgrading symfony/polyfill-php73 (v1.25.0 => v1.26.0)
  - Upgrading symfony/polyfill-php80 (v1.25.0 => v1.26.0)
  - Upgrading symfony/polyfill-php81 (v1.25.0 => v1.26.0)
  - Upgrading symfony/service-contracts (v2.5.1 => v2.5.2)
  - Upgrading symfony/string (v5.4.8 => v5.4.10)
  - Upgrading symfony/translation (v5.4.8 => v5.4.9)
  - Upgrading symfony/translation-contracts (v2.5.1 => v2.5.2)
  - Upgrading symfony/var-dumper (v5.4.8 => v5.4.9)
  - Upgrading symfony/yaml (v5.4.3 => v5.4.10)
  - Upgrading tecnickcom/tc-lib-barcode (1.17.11 => 1.17.14)
  - Upgrading tecnickcom/tc-lib-color (1.14.10 => 1.14.14)
  - Upgrading webmozart/assert (1.10.0 => 1.11.0)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 76 installs, 99 updates, 10 removals
  - Syncing symfony/deprecation-contracts (v2.5.2) into cache
    Failed to download psr/http-client from dist: /var/www/html/snipe-it/snipe-it/vendor/psr/http-client does not exist and could not be created.
    Now trying to download from source
  - Syncing psr/http-client (1.0.1) into cache
  - Syncing guzzlehttp/psr7 (2.4.0) into cache
  - Syncing guzzlehttp/promises (1.5.1) into cache
  - Syncing guzzlehttp/guzzle (7.4.5) into cache
  - Syncing symfony/polyfill-mbstring (v1.26.0) into cache
  - Syncing alek13/slack (2.2.1) into cache

In Filesystem.php line 268:

  /var/www/html/snipe-it/snipe-it/vendor/tmilos does not exist and could not be created.

update [--with WITH] [--prefer-source] [--prefer-dist] [--prefer-install PREFER-INSTALL] [--dry-run] [--dev] [--no-dev] [--lock] [--no-install] [--no-autoloader] [--no-suggest] [--no-progress] [-w|--with-dependencies] [-W|--with-all-dependencies] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--apcu-autoloader-prefix APCU-AUTOLOADER-PREFIX] [--ignore-platform-req IGNORE-PLATFORM-REQ] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [-i|--interactive] [--root-reqs] [--] [<packages>...]
mikeroq commented 2 years ago

Does snipeadmin own /var/www/html/snipe-it/snipe-it?

astrugatch commented 2 years ago

It is owned by www-data

mikeroq commented 2 years ago

User and group www-data?

astrugatch commented 2 years ago

drwxr-xr-x 18 www-data www-data 4096 Jul 5 10:20 snipe-it

snipe commented 2 years ago

Unless you’re a developer, you shouldn’t run composer update on its own. That updates our dependencies and can lead to really unpredictable behavior, and generates a new package.lock, which means git pulls will fail in the future.

mikeroq commented 2 years ago

cd to /var/www/html/snipe-it/

sudo chown -R snipeadmin:www-data snipe-it
sudo usermod -a -G www-data snipeadmin
sudo find snipe-it -type f -exec chmod 664 {} \;
sudo chgrp -R www-data snipe-it/storage snipe-it/bootstrap/cache snipe-it/public/uploads
sudo chmod -R ug+rwx snipe-it/storage snipe-it/bootstrap/cache snipe-it/public/uploads

Then try the php upgrade.php again.

astrugatch commented 2 years ago

@snipe

What is the proper procedure for updating composer?

@mikeroq I'm rolling back a snapshot so I can test your permissions fix without the composer update that @snipe recommended not running.

mikeroq commented 2 years ago

I cloned version 5.2.0 and I also get the barryvdh dompdf error, but my composer seems to go though just fine. It's still going (seems slow AF on windows).

This part on yours however from the beginning:

  - Syncing symfony/deprecation-contracts (v2.5.1) into cache
Cloning failed using an ssh key for authentication, enter your GitHub credentials to access private repos
When working with _public_ GitHub repositories only, head to https://github.com/settings/tokens/new?scopes=&description=Composer+on+snipeit+2022-07-05+0954 to retrieve a token.
This token will have read-only permission for public information only.
When you need to access _private_ GitHub repositories as well, go to https://github.com/settings/tokens/new?scopes=repo&description=Composer+on+snipeit+2022-07-05+0954
Note that such tokens have broad read/write permissions on your behalf, even if not needed by Composer.
Tokens will be stored in plain text in "/var/www/.config/composer/auth.json" for future use by Composer.
For additional information, check https://getcomposer.org/doc/articles/authentication-for-private-packages.md#github-oauth
Token (hidden):
mikeroq commented 2 years ago

Maybe this would help that: sudo apt-get install unzip

astrugatch commented 2 years ago

unzip is already installed.

Ran the upgrade twice. First time got the barryvdh dompdf error, second time it went through after discarding lots of changes.

@snipe Are those discard changes requests due to me possibly doing a composer update in the past? I really don't dig into this server that often (as my version probably shows). So I don't know if I tried that troubleshooting in the past.

mikeroq commented 2 years ago

unzip is already installed.

Ran the upgrade twice. First time got the barryvdh dompdf error, second time it went through after discarding lots of changes.

@snipe Are those discard changes requests due to me possibly doing a composer update in the past? I really don't dig into this server that often (as my version probably shows). So I don't know if I tried that troubleshooting in the past.

Was the upgrade successful?

astrugatch commented 2 years ago

Yes. Upgraded to 6.0.6. Site loads properly even after clearing caches/using private window. Still keeping my 5.2 snapshot around for a while, while my team uses it, just in case.

snipe commented 2 years ago

This is basically the same as #11385