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

Issue updating from 5.1.4 to 5.2 - likely permissions #10162

Closed astrugatch closed 3 years ago

astrugatch commented 3 years ago

Debug mode

Describe the bug

Attempting to upgrade from 5.1.4 to 5.2. Running php upgrade.php and getting permission errors. I don't see the exact issue on Common Issues page so I don't know the exact cause.

Reproduction steps

  1. git pull
  2. run php upgrade.php ...

Expected behavior

Upgraded to latest

Screenshots


WELCOME TO THE SNIPE-IT UPGRADER!

This script will attempt to:


STEP 1: Checking PHP requirements:

Current PHP version: (7.4.3) is at least 7.2.5 - 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! √ tokenizer is installed! √ xml is installed! √ zip is installed!


STEP 2: Backing up database:

-- Starting backup... Backup failed because: mkdir(): Permission denied.


STEP 3: Putting application into maintenance mode:

-- Failed to enter maintenance mode. file_put_contents(/var/www/html/snipe-it/snipe-it/storage/framework/down): failed to open stream: Permission denied


STEP 4: Pulling latest from Git (master branch):

Git is installed. error: cannot open .git/FETCH_HEAD: Permission denied fatal: Unable to create '/var/www/html/snipe-it/snipe-it/.git/index.lock': Permission denied error: cannot open .git/FETCH_HEAD: Permission denied



Step 5: Cleaning up old cached files:

√ No bootstrap/cache/compiled.php, so nothing to delete. √ No bootsrap/cache/services.php, so nothing to delete. √ No bootstrap/cache/config.php, so nothing to delete.

-- Configuration cache cleared! -- Failed to clear cache. Make sure you have the appropriate permissions. -- Route cache cleared! -- Compiled views cleared!


Step 6: Updating composer dependencies: (This may take a moment.)

√ Local composer.phar detected, so we'll use that.

-- Updating local composer.phar

[Composer\Downloader\FilesystemException] Filesystem exception: Composer update failed: "/var/www/html/snipe-it/snipe-it/composer.phar" could not be written. rename(/home/snipeadmin/.cache/composer/composer-temp.phar,/var/www/html/snipe-it/snipe-it/composer.phar): Permission denied

self-update [-r|--rollback] [--clean-backups] [--no-progress] [--update-keys] [--stable] [--preview] [--snapshot] [--1] [--2] [--set-channel-only] [--] []

Upgrading to version 2.1.8 (stable channel).

Class ParsedownTest located in ./vendor/erusev/parsedown/test/ParsedownTest.php does not comply with psr-0 autoloading standard. Skipping.

[ErrorException] file_put_contents(/var/www/html/snipe-it/snipe-it/vendor/composer/autoload_psr4.php): failed to open stream: Permission denied

dump-autoload [--no-scripts] [-o|--optimize] [-a|--classmap-authoritative] [--apcu] [--apcu-prefix APCU-PREFIX] [--no-dev] [--ignore-platform-req IGNORE-PLATFORM-REQ] [--ignore-platform-reqs]

Installing dependencies from lock file Verifying lock file contents can be installed on current platform. Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. It is recommended that you run composer update or composer update <package name>. Nothing to install, update or remove

[ErrorException] file_put_contents(/var/www/html/snipe-it/snipe-it/vendor/composer/installed.json): failed to open stream: Permission denied

install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-suggest] [--no-dev] [--no-autoloader] [--no-scripts] [--no-progress] [--no-install] [-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] [--] []...

Generating optimized autoload files


Step 7: Migrating database:

Nothing to migrate.


Step 8: Checking for OAuth keys:

√ OAuth keys detected. Skipping passport install.


Step 9: Taking application out of maintenance mode:

-- Application is already up.

---------------------- FINISHED! ----------------------- All done! Clear your browser cookies and re-login to use your upgraded Snipe-IT!

Snipe-IT Version

5.1.4

Operating System

Ubuntu 20.04

Web Server

Apache

PHP Version

7.4.3

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

Is this a fresh install or an upgrade? upgrade What OS and web server you're running Snipe-IT on Ubuntu 20.04 Apache What method you used to install Snipe-IT (install.sh, manual installation, docker, etc) git Include what you've done so far in the installation, and if you got any error messages along the way. Checking git issues that appear similar but don't see the resolution others have found Indicate whether or not you've manually edited any data directly in the database no

welcome[bot] commented 3 years ago

👋 Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.

astrugatch commented 3 years ago

I ran:

chown -R www-data:www-data /var/www/html/snipe-it/snipe-it usermod -a -G www-data snipeadmin

and I'm getting fewer errors but am still seeing:


Step 6: Updating composer dependencies: (This may take a moment.)

√ Local composer.phar detected, so we'll use that.

-- Updating local composer.phar

Cannot create cache directory /var/www/.cache/composer/repo/https---repo.packagist.org/, or directory is not writable. Proceeding without cache Cannot create cache directory /var/www/.cache/composer/files/, or directory is not writable. Proceeding without cache

[ErrorException] fileowner(): stat failed for /var/www/.config/composer

self-update [-r|--rollback] [--clean-backups] [--no-progress] [--update-keys] [--stable] [--preview] [--snapshot] [--1] [--2] [--set-channel-only] [--] []

Cannot create cache directory /var/www/.cache/composer/repo/https---repo.packagist.org/, or directory is not writable. Proceeding without cache Cannot create cache directory /var/www/.cache/composer/files/, or directory is not writable. Proceeding without cache Class ParsedownTest located in ./vendor/erusev/parsedown/test/ParsedownTest.php does not comply with psr-0 autoloading standard. Skipping.

Illuminate\Foundation\ComposerScripts::postAutoloadDump Cannot create cache directory /var/www/.cache/composer/repo/https---repo.packagist.org/, or directory is not writable. Proceeding without cache Cannot create cache directory /var/www/.cache/composer/files/, or directory is not writable. Proceeding without cache Installing dependencies from lock file Verifying lock file contents can be installed on current platform. Package operations: 1 install, 63 updates, 1 removal

astrugatch commented 3 years ago

I thought I caught my permissions issues, but when I upgrade I don't get errors, but after the upgrade completes no page loads.

Output from running upgrade.php:

` snipeadmin@snipeit:/var/www/html/snipe-it/snipe-it$ php upgrade.php

WELCOME TO THE SNIPE-IT UPGRADER!

This script will attempt to:


STEP 1: Checking PHP requirements:

Current PHP version: (7.4.3) is at least 7.2.5 - 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! √ tokenizer is installed! √ xml is installed! √ zip is installed!


STEP 2: Backing up database:

-- Starting backup... Dumping database snipeit... Determining files to backup... Zipping 114 files and directories... Created zip containing 114 files and directories. Size is 145.18 KB Copying zip to disk named backup... Successfully copied zip to disk named backup. Backup completed!


STEP 3: Putting application into maintenance mode:

-- Application is now in maintenance mode.


STEP 4: Pulling latest from Git (master branch):

Git is installed. Already on 'master' -- Saved working directory and index state WIP on master: ac7636414 Merge pull request #10172 from snipe/fixes/S3_upload_preview -- M public/uploads/barcodes/invalid_barcode.gif M storage/private_uploads/signatures/.gitkeep Your branch is up to date with 'origin/master'. -- Already up to date.


Step 5: Cleaning up old cached files:

√ No bootstrap/cache/compiled.php, so nothing to delete. √ No bootsrap/cache/services.php, so nothing to delete. √ No bootstrap/cache/config.php, so nothing to delete.

-- Configuration cache cleared! -- Application cache cleared! -- Route cache cleared! -- Compiled views cleared!


Step 6: Updating composer dependencies: (This may take a moment.)

-- We couldn't find a local composer.phar. No worries, trying globally.

Class ParsedownTest located in ./vendor/erusev/parsedown/test/ParsedownTest.php does not comply with psr-0 autoloading standard. Skipping.

Illuminate\Foundation\ComposerScripts::postAutoloadDump Installing dependencies from lock file Verifying lock file contents can be installed on current platform. Package operations: 1 install, 63 updates, 1 removal

  • Syncing symfony/polyfill-php80 (v1.23.0) into cache
  • Syncing symfony/polyfill-php72 (v1.23.0) into cache
  • Syncing symfony/polyfill-mbstring (v1.23.0) into cache
  • Syncing symfony/var-dumper (v4.4.25) into cache
  • Syncing tightenco/collect (v8.34.0) into cache
  • Syncing psr/log (1.1.4) into cache
  • Syncing symfony/polyfill-ctype (v1.23.0) into cache
  • Syncing symfony/css-selector (v4.4.25) into cache
  • Syncing symfony/routing (v4.4.25) into cache
  • Syncing symfony/process (v4.4.25) into cache
  • Syncing symfony/polyfill-php73 (v1.23.0) into cache
  • Syncing symfony/polyfill-intl-normalizer (v1.23.0) into cache
  • Syncing symfony/polyfill-intl-idn (v1.23.0) into cache
  • Syncing symfony/deprecation-contracts (v2.4.0) into cache
  • Syncing symfony/mime (v5.3.2) into cache
  • Syncing symfony/http-foundation (v4.4.25) into cache
  • Syncing symfony/http-client-contracts (v2.4.0) into cache
  • Syncing symfony/event-dispatcher (v4.4.25) into cache
  • Syncing symfony/debug (v4.4.25) into cache
  • Syncing symfony/error-handler (v4.4.25) into cache
  • Syncing symfony/http-kernel (v4.4.25) into cache
  • Syncing symfony/finder (v4.4.25) into cache
  • Syncing psr/container (1.1.1) into cache
  • Syncing symfony/service-contracts (v2.4.0) into cache
  • Syncing symfony/console (v4.4.25) into cache
  • Syncing symfony/polyfill-iconv (v1.23.0) into cache
  • Syncing swiftmailer/swiftmailer (v6.2.7) into cache
  • Syncing opis/closure (3.6.2) into cache
  • Syncing symfony/translation-contracts (v2.4.0) into cache
  • Syncing symfony/translation (v4.4.25) into cache
  • Syncing nesbot/carbon (2.49.0) into cache
  • Syncing league/flysystem (1.1.4) into cache
  • Syncing league/commonmark (1.6.4) into cache
  • Syncing doctrine/inflector (1.4.4) into cache
  • Syncing laravel/framework (v6.20.29) into cache
  • Syncing adldap2/adldap2 (v10.3.2) into cache
  • Syncing guzzlehttp/psr7 (1.8.2) into cache
  • Syncing guzzlehttp/promises (1.4.1) into cache
  • Syncing barryvdh/laravel-debugbar (v3.6.2) into cache
  • Syncing doctrine/annotations (1.13.1) into cache
  • Syncing doctrine/cache (1.11.3) into cache
  • Syncing doctrine/deprecations (v0.5.3) into cache
  • Syncing doctrine/dbal (2.13.2) into cache
  • Syncing squizlabs/php_codesniffer (3.6.0) into cache
  • Syncing laravel/helpers (v1.4.1) into cache
  • Syncing symfony/psr-http-message-bridge (v2.1.0) into cache
  • Syncing phpseclib/phpseclib (2.0.32) into cache
  • Syncing nyholm/psr7 (1.4.0) into cache
  • Syncing lcobucci/jwt (3.4.5) into cache
  • Syncing defuse/php-encryption (v2.3.1) into cache
  • Syncing league/oauth2-server (8.3.1) into cache
  • Syncing firebase/php-jwt (v5.4.0) into cache
  • Syncing nikic/php-parser (v4.10.5) into cache
  • Syncing psy/psysh (v0.10.8) into cache
  • Syncing laravel/tinker (v2.6.1) into cache
  • Syncing mtdowling/jmespath.php (2.6.1) into cache
  • Syncing aws/aws-sdk-php (3.185.0) into cache
  • Syncing filp/whoops (2.13.0) into cache
  • Syncing onelogin/php-saml (3.6.1) into cache
  • Syncing webmozart/assert (1.10.0) into cache
  • Syncing phpspec/prophecy (1.13.0) into cache
  • Syncing spatie/db-dumper (2.21.1) into cache
  • Syncing tecnickcom/tc-lib-color (1.14.6) into cache
  • Syncing tecnickcom/tc-lib-barcode (1.17.6) into cache 0 [>---------------------------] 0 [>---------------------------] 0 [>---------------------------] - Removing dnoegel/php-xdg-base-dir (v0.1.1)
  • Upgrading symfony/polyfill-php80 (v1.22.0 => v1.23.0): Checking out eca0bf41ed from cache
  • Upgrading symfony/polyfill-php72 (v1.22.0 => v1.23.0): Checking out 9a142215a3 from cache
  • Upgrading symfony/polyfill-mbstring (v1.22.0 => v1.23.0): Checking out 2df51500ad from cache
  • Upgrading symfony/var-dumper (v4.4.19 => v4.4.25): Checking out 31ea689a8e from cache
  • Upgrading tightenco/collect (v8.19.0 => v8.34.0): Checking out b069783ab0 from cache
  • Upgrading psr/log (1.1.3 => 1.1.4): Checking out d49695b909 from cache
  • Upgrading symfony/polyfill-ctype (v1.22.0 => v1.23.0): Checking out 46cd95797e from cache
  • Upgrading symfony/css-selector (v4.4.19 => v4.4.25): Checking out c1e29de6dc from cache
  • Upgrading symfony/routing (v4.4.19 => v4.4.25): Checking out 3a3c2f197a from cache
  • Upgrading symfony/process (v4.4.19 => v4.4.25): Checking out cd61e6dd27 from cache
  • Upgrading symfony/polyfill-php73 (v1.22.0 => v1.23.0): Checking out fba8933c38 from cache
  • Upgrading symfony/polyfill-intl-normalizer (v1.22.0 => v1.23.0): Checking out 8590a5f561 from cache
  • Upgrading symfony/polyfill-intl-idn (v1.22.0 => v1.23.0): Checking out 65bd267525 from cache
  • Upgrading symfony/deprecation-contracts (v2.2.0 => v2.4.0): Checking out 5f38c8804a from cache
  • Upgrading symfony/mime (v5.2.2 => v5.3.2): Checking out 47dd791215 from cache
  • Upgrading symfony/http-foundation (v4.4.19 => v4.4.25): Checking out 0c79d5a65a from cache
  • Upgrading symfony/http-client-contracts (v2.3.1 => v2.4.0): Checking out 7e82f6084d from cache
  • Upgrading symfony/event-dispatcher (v4.4.19 => v4.4.25): Checking out 047773e701 from cache
  • Upgrading symfony/debug (v4.4.19 => v4.4.25): Checking out a8d2d5c944 from cache
  • Upgrading symfony/error-handler (v4.4.19 => v4.4.25): Checking out 310a756cec from cache
  • Upgrading symfony/http-kernel (v4.4.19 => v4.4.25): Checking out 3795165596 from cache
  • Upgrading symfony/finder (v4.4.19 => v4.4.25): Checking out ed33314396 from cache
  • Upgrading psr/container (1.0.0 => 1.1.1): Checking out 8622567409 from cache
  • Upgrading symfony/service-contracts (v2.2.0 => v2.4.0): Checking out f040a30e04 from cache
  • Upgrading symfony/console (v4.4.19 => v4.4.25): Checking out a62acecdf5 from cache
  • Upgrading symfony/polyfill-iconv (v1.22.0 => v1.23.0): Checking out 63b5bb7db8 from cache
  • Upgrading swiftmailer/swiftmailer (v6.2.5 => v6.2.7): Checking out 15f7faf850 from cache
  • Upgrading opis/closure (3.6.1 => 3.6.2): Checking out 06e2ebd25f from cache
  • Upgrading symfony/translation-contracts (v2.3.0 => v2.4.0): Checking out 95c812666f from cache
  • Upgrading symfony/translation (v4.4.19 => v4.4.25): Checking out dfe132c5c6 from cache nesbot/carbon has modified files: M bin/carbon Discard changes [y,n,v,d,s,?]? y
  • Upgrading nesbot/carbon (2.44.0 => 2.49.0): Checking out 93d9db91c0 from cache
  • Upgrading league/flysystem (1.1.3 => 1.1.4): Checking out f3ad69181b from cache
  • Upgrading league/commonmark (1.5.7 => 1.6.4): Checking out c3c8b7217c from cache
  • Upgrading doctrine/inflector (1.4.3 => 1.4.4): Checking out 4bd5c1cdfc from cache
  • Upgrading laravel/framework (v6.20.16 => v6.20.29): Checking out 00fa9c04ae from cache
  • Upgrading adldap2/adldap2 (v10.3.1 => v10.3.2): Checking out b2203d800c from cache
  • Upgrading guzzlehttp/psr7 (1.7.0 => 1.8.2): Checking out dc960a9129 from cache
  • Upgrading guzzlehttp/promises (1.4.0 => 1.4.1): Checking out 8e7d04f1f6 from cache
  • Upgrading barryvdh/laravel-debugbar (v3.5.2 => v3.6.2): Checking out 70b8975491 from cache
  • Upgrading doctrine/annotations (1.11.1 => 1.13.1): Checking out e6e7b7d5b4 from cache
  • Upgrading doctrine/cache (1.10.2 => 1.11.3): Checking out 3bb5588cec from cache
  • Installing doctrine/deprecations (v0.5.3): Cloning 9504165960 from cache
  • Upgrading doctrine/dbal (2.10.4 => 2.13.2): Checking out 8dd39d2ead from cache
  • Upgrading squizlabs/php_codesniffer (3.5.8 => 3.6.0): Checking out ffced0d2c8 from cache
  • Upgrading laravel/helpers (v1.4.0 => v1.4.1): Checking out febb10d8da from cache
  • Upgrading symfony/psr-http-message-bridge (v2.0.2 => v2.1.0): Checking out 81db2d4ae8 from cache
  • Upgrading phpseclib/phpseclib (2.0.30 => 2.0.32): Checking out f5c4c19880 from cache
  • Upgrading nyholm/psr7 (1.3.2 => 1.4.0): Checking out 23ae1f00fb from cache
  • Upgrading lcobucci/jwt (3.4.3 => 3.4.5): Checking out 511629a544 from cache
  • Upgrading defuse/php-encryption (v2.2.1 => v2.3.1): Checking out 77880488b9 from cache
  • Upgrading league/oauth2-server (8.2.4 => 8.3.1): Checking out 97dbc97b3b from cache
  • Upgrading firebase/php-jwt (v5.2.0 => v5.4.0): Checking out d2113d9b2e from cache
  • Upgrading nikic/php-parser (v4.10.4 => v4.10.5): Checking out 4432ba399e from cache
  • Upgrading psy/psysh (v0.10.6 => v0.10.8): Checking out e4573f4775 from cache
  • Upgrading laravel/tinker (v2.6.0 => v2.6.1): Checking out 04ad32c1a3 from cache
  • Upgrading mtdowling/jmespath.php (2.6.0 => 2.6.1): Checking out 9b87907a81 from cache
  • Upgrading aws/aws-sdk-php (3.173.0 => 3.185.0): Checking out 6c919bc226 from cache
  • Upgrading filp/whoops (2.10.0 => 2.13.0): Checking out 2edbc73a46 from cache
  • Upgrading onelogin/php-saml (3.5.1 => 3.6.1): Checking out a7328b1188 from cache
  • Upgrading webmozart/assert (1.9.1 => 1.10.0): Checking out 6964c76c78 from cache
  • Upgrading phpspec/prophecy (1.12.2 => 1.13.0): Checking out be1996ed8a from cache
  • Upgrading spatie/db-dumper (2.21.0 => 2.21.1): Checking out 05e5955fb8 from cache
  • Upgrading tecnickcom/tc-lib-color (1.14.1 => 1.14.6): Checking out 83cdb57fd9 from cache
  • Upgrading tecnickcom/tc-lib-barcode (1.17.1 => 1.17.6): Checking out a8a7183e2b from cache 0 [>---------------------------] 0 [>---------------------------] 0 [>---------------------------]Package doctrine/reflection is abandoned, you should avoid using it. Use roave/better-reflection instead. Package patchwork/utf8 is abandoned, you should avoid using it. Use symfony/polyfill-mbstring or symfony/string instead. Package fzaninotto/faker is abandoned, you should avoid using it. No replacement was suggested. Package phpunit/php-token-stream is abandoned, you should avoid using it. No replacement was suggested. Generating optimized autoload files Class ParsedownTest located in ./vendor/erusev/parsedown/test/ParsedownTest.php does not comply with psr-0 autoloading standard. Skipping. Illuminate\Foundation\ComposerScripts::postAutoloadDump 65 packages you are using are looking for funding. Use the composer fund command to find out more! Generating optimized autoload files Generated optimized autoload files containing 5925 classes

Step 7: Migrating database:

Migrating: 2019_04_06_060145_add_user_skin_setting Migrated: 2019_04_06_060145_add_user_skin_setting (0.02 seconds) Migrating: 2019_04_06_205355_add_setting_allow_user_skin Migrated: 2019_04_06_205355_add_setting_allow_user_skin (0.01 seconds) Migrating: 2020_08_11_200712_add_saml_key_rollover Migrated: 2020_08_11_200712_add_saml_key_rollover (0.01 seconds) Migrating: 2021_03_18_184102_adds_several_ldap_fields Migrated: 2021_03_18_184102_adds_several_ldap_fields (0.04 seconds) Migrating: 2021_04_07_001811_add_ldap_dept Migrated: 2021_04_07_001811_add_ldap_dept (0.03 seconds) Migrating: 2021_04_14_180125_add_ids_to_tables Migrated: 2021_04_14_180125_add_ids_to_tables (0.03 seconds) Migrating: 2021_06_07_155421_add_serial_number_indexes Migrated: 2021_06_07_155421_add_serial_number_indexes (0.02 seconds) Migrating: 2021_06_07_155436_add_company_id_indexes Migrated: 2021_06_07_155436_add_company_id_indexes (0.11 seconds) Migrating: 2021_07_28_031345_add_client_side_l_d_a_p_cert_to_settings Migrated: 2021_07_28_031345_add_client_side_l_d_a_p_cert_to_settings (0 seconds) Migrating: 2021_07_28_040554_add_client_side_l_d_a_p_key_to_settings Migrated: 2021_07_28_040554_add_client_side_l_d_a_p_key_to_settings (0 seconds) Migrating: 2021_08_11_005206_add_depreciation_minimum_value Migrated: 2021_08_11_005206_add_depreciation_minimum_value (0.02 seconds) Migrating: 2021_08_24_124354_make_ldap_client_certs_nullable Migrated: 2021_08_24_124354_make_ldap_client_certs_nullable (0.01 seconds)


Step 8: Checking for OAuth keys:

√ OAuth keys detected. Skipping passport install.


Step 9: Taking application out of maintenance mode:

-- Application is now live.

---------------------- FINISHED! ----------------------- All done! Clear your browser cookies and re-login to use your upgraded Snipe-IT! `