Laravel 6.x
Php 7.2
I tried to install sentry via composer with composer require sentry/sentry-laravel:1.3.0 and I got Required package "sentry/sentry" is not installed: cannot detect its version. I tried installing sentry/sentry and sentry/sdk one by one but still same error
Here is my composer.json
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": "^7.1.3",
"anhskohbo/no-captcha": "^3.0",
"doctrine/dbal": "^2.9",
"facade/ignition": "^1.4",
"fideloper/proxy": "^4.0",
"iatstuti/laravel-cascade-soft-deletes": "^2.0",
"laravel/framework": "^6.0",
"laravel/tinker": "^1.0",
"laravelcollective/html": "~6.0",
"spatie/laravel-image-optimizer": "^1.3"
},
"require-dev": {
"barryvdh/laravel-debugbar": "^3.2",
"barryvdh/laravel-ide-helper": "^2.6",
"filp/whoops": "^2.0",
"fzaninotto/faker": "^1.4",
"mockery/mockery": "^1.0",
"nunomaduro/collision": "^2.0",
"nunomaduro/phpinsights": "^1.9",
"phpunit/phpunit": "^7.0"
},
"autoload": {
"files": [
"app/Http/helpers.php"
],
"classmap": [
"database/seeds",
"database/factories"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"extra": {
"laravel": {
"dont-discover": [
]
}
},
"scripts": {
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"@php artisan key:generate"
],
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover"
]
},
"config": {
"preferred-install": "dist",
"sort-packages": true,
"optimize-autoloader": true
},
"minimum-stability": "dev",
"prefer-stable": true
}
The complete Error:
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover
OutOfBoundsException : Required package "sentry/sentry" is not installed: cannot detect its version
at /Users/rizkyarlin/projects/laravel/simrs/vendor/ocramius/package-versions/src/PackageVersions/Versions.php:175
171| if (isset(self::VERSIONS[$packageName])) {
172| return self::VERSIONS[$packageName];
173| }
174|
> 175| throw new \OutOfBoundsException(
176| 'Required package "' . $packageName . '" is not installed: cannot detect its version'
177| );
178| }
179| }
Exception trace:
1 PackageVersions\Versions::getVersion("sentry/sentry")
/Users/rizkyarlin/projects/laravel/simrs/vendor/jean85/pretty-package-versions/src/PrettyVersions.php:13
2 Jean85\PrettyVersions::getVersion("sentry/sentry")
/Users/rizkyarlin/projects/laravel/simrs/vendor/sentry/sentry/src/ClientBuilder.php:111
Please use the argument -v to see more details.
Script @php artisan package:discover handling the post-autoload-dump event returned with error code 1
Installation failed, reverting ./composer.json to its original content.
I tried composer require sentry/sentry-laravel:1.3.0 on another laravel project and it works. What am I missing here?
@Jean85 do you have any clue what might be causing this?
I would like to see the output before that error, to see which packages got installed. But it's really strange, because requiring sentry/sentry-laravel will require sentry/sentry-skd, which in turn required sentry/sentry...
I'll try that locally.
I've tried a composer install with that composer.json, and it got stuck on the scripts because I do not have the Laravel skeleton, but that's ok.
Afterward I did a composer require sentry/sentry-laravel:1.3.0 and I got this:
Package operations: 15 installs, 0 updates, 0 removals
- Installing psr/http-factory (1.0.1): Loading from cache
- Installing http-interop/http-factory-guzzle (1.0.0): Loading from cache
- Installing php-http/discovery (1.7.0): Loading from cache
- Installing clue/stream-filter (v1.4.1): Loading from cache
- Installing php-http/message-factory (v1.0.2): Loading from cache
- Installing php-http/message (1.8.0): Loading from cache
- Installing php-http/promise (v1.0.0): Loading from cache
- Installing psr/http-client (1.0.0): Loading from cache
- Installing php-http/httplug (v2.0.0): Loading from cache
- Installing php-http/curl-client (2.0.0): Loading from cache
- Installing zendframework/zend-diactoros (2.1.3): Loading from cache
- Installing php-http/client-common (2.0.0): Loading from cache
- Installing sentry/sentry (2.2.1): Loading from cache
- Installing sentry/sentry-laravel (1.3.0): Loading from cache
And then the same Laravel error. It seems to work for me, tried with Composer version 1.7.3 and 1.9.0 (latest).
composer version: 1.8.6
I tried to rerun composer require sentry/sentry-laravel:1.3.0
Here's the full result
simrs git:(sentry) ✗ composer require sentry/sentry-laravel:1.3.0
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 15 installs, 0 updates, 0 removals
- Installing psr/http-factory (1.0.1): Loading from cache
- Installing http-interop/http-factory-guzzle (1.0.0): Loading from cache
- Installing php-http/discovery (1.7.0): Loading from cache
- Installing clue/stream-filter (v1.4.1): Loading from cache
- Installing php-http/message-factory (v1.0.2): Loading from cache
- Installing php-http/message (1.8.0): Loading from cache
- Installing php-http/promise (v1.0.0): Loading from cache
- Installing psr/http-client (1.0.0): Loading from cache
- Installing php-http/httplug (v2.0.0): Loading from cache
- Installing php-http/curl-client (2.0.0): Loading from cache
- Installing zendframework/zend-diactoros (2.1.3): Loading from cache
- Installing php-http/client-common (2.0.0): Loading from cache
- Installing sentry/sentry (2.2.1): Loading from cache
- Installing sentry/sdk (2.0.4)
- Installing sentry/sentry-laravel (1.3.0): Loading from cache
php-http/discovery suggests installing puli/composer-plugin (Sets up Puli which is recommended for Discovery to work. Check http://docs.php-http.org/en/latest/discovery.html for more details.)
php-http/message suggests installing slim/slim (Used with Slim Framework PSR-7 implementation)
php-http/client-common suggests installing php-http/logger-plugin (PSR-3 Logger plugin)
php-http/client-common suggests installing php-http/cache-plugin (PSR-6 Cache plugin)
php-http/client-common suggests installing php-http/stopwatch-plugin (Symfony Stopwatch plugin)
Writing lock file
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover
OutOfBoundsException : Required package "sentry/sentry" is not installed: cannot detect its version
at /Users/rizkyarlin/projects/laravel/simrs/vendor/ocramius/package-versions/src/PackageVersions/Versions.php:175
171| if (isset(self::VERSIONS[$packageName])) {
172| return self::VERSIONS[$packageName];
173| }
174|
> 175| throw new \OutOfBoundsException(
176| 'Required package "' . $packageName . '" is not installed: cannot detect its version'
177| );
178| }
179| }
Exception trace:
1 PackageVersions\Versions::getVersion("sentry/sentry")
/Users/rizkyarlin/projects/laravel/simrs/vendor/jean85/pretty-package-versions/src/PrettyVersions.php:13
2 Jean85\PrettyVersions::getVersion("sentry/sentry")
/Users/rizkyarlin/projects/laravel/simrs/vendor/sentry/sentry/src/ClientBuilder.php:111
Please use the argument -v to see more details.
Script @php artisan package:discover handling the post-autoload-dump event returned with error code 1
Installation failed, reverting ./composer.json to its original content.
Thank you very much for the responses 👍
I deleted the vendor and run composer install. Now it's working.
It got something to do with the ocramius/package-versions.
Before I close the issue, can you tell me what was the problem? I need to understand this, it drove me crazy yesterday 🤦♂
The problem seems to be that the Illuminate\Foundation\ComposerScripts::postAutoloadDump is running BEFORE the ocramius/package-versions, so when that package is used, it's NOT ready yet.
Thanks
I've backported https://github.com/Ocramius/PackageVersions/pull/82 with https://github.com/Ocramius/PackageVersions/pull/112, and it got released as 1.4.1, which is compatible with PHP 7.1.
This issue should no longer be present.
Most helpful comment
The problem seems to be that the
Illuminate\Foundation\ComposerScripts::postAutoloadDumpis running BEFORE theocramius/package-versions, so when that package is used, it's NOT ready yet.