Sentry-laravel: Can't install Sentry - Composer error

Created on 18 Mar 2019  Ā·  32Comments  Ā·  Source: getsentry/sentry-laravel

Hi,

I can't install the package through composer.

Here is the error:

  Problem 1
    - Installation request for sentry/sentry-laravel ^1.0 -> satisfiable by sentry/sentry-laravel[1.0.0, 1.0.0-beta1, 1.0.0-beta2, 1.0.0-beta3, 1.0.0-beta4, 1.0.0-beta5, 1.0.1, 1.0.x-dev].
    - Can only install one of: php-http/httplug[v2.0.0, v1.1.0].
    - Can only install one of: php-http/httplug[v1.1.0, v2.0.0].
    - Can only install one of: php-http/httplug[v1.1.0, v2.0.0].
    - Conclusion: install php-http/httplug v1.1.0
    - Installation request for php-http/httplug (locked at v2.0.0) -> satisfiable by php-http/httplug[v2.0.0].
support

Most helpful comment

So it looks like there is some sort of incompatibility that composer for some reason is not complaining about (that we believe should be happening).

The problem is that you guys are using laravel/passport that requires zendframework/zend-diactoros:^1.0 but also requiring the php-http/curl-client:^2.0 (directly or indirectly) which requires zendframework/zend-diactoros:^2.0 (or another package that implements the PSR-17 response factory).

There are 2 solutions.

  • Upgrade laravel/passport to ^7.2.2 which allows for the correct zendframework/zend-diactoros:^2.0 to be installed
  • Downgrade/install php-http/curl-client:^1.0

We are seeing if there is something we can do from our side or we might be doing it wrong or there is a problem in the dependencies of httplug, but the above solutions should get you moving with using sentry/sentry-laravel:^1.0.

All 32 comments

I believe that is because you are using httplug 2.0 in your application and the "default integration" supplies a 1.x version of the curl client which is incompatible with httplug 2.x.

You should be able to install by requiring the base SDK directly and supplying your own httplug client:

composer require sentry/sentry:^2.0 php-http/curl-client guzzlehttp/psr7 sentry/sentry-laravel:^1.0

(you can ofcourse switch out the curl client if you want)

Ah, i tried, but now i get this error :

  Problem 1
    - Conclusion: don't install php-http/curl-client 2.0.0
    - Installation request for sentry/sentry-laravel ^1.0 -> satisfiable by sentry/sentry-laravel[1.0.0, 1.0.0-beta1, 1.0.0-beta2, 1.0.0-beta3, 1.0.0-beta4, 1.0.0-beta5, 1.0.1, 1.0.x-dev].
    - sentry/sentry-laravel 1.0.0 requires sentry/sdk ^2.0 -> satisfiable by sentry/sdk[2.0.0].
    - sentry/sentry-laravel 1.0.1 requires sentry/sdk ^2.0 -> satisfiable by sentry/sdk[2.0.0].
    - sentry/sentry-laravel 1.0.x-dev requires sentry/sdk ^2.0 -> satisfiable by sentry/sdk[2.0.0].
    - sentry/sdk 2.0.0 requires php-http/curl-client ^1.0 -> satisfiable by php-http/curl-client[1.7.x-dev].
    - Can only install one of: php-http/curl-client[2.x-dev, 1.7.x-dev].
    - don't install php-http/curl-client 2.x-dev|install php-http/curl-client dev-master
    - Installation request for php-http/curl-client ^2.0 -> satisfiable by php-http/curl-client[2.0.0, 2.x-dev].
    - php-http/curl-client dev-master requires php-http/httplug ^2.0 -> satisfiable by php-http/httplug[v2.0.0, 2.0.x-dev].
    - Can only install one of: php-http/httplug[v1.1.0, 2.0.x-dev].
    - Can only install one of: php-http/httplug[v2.0.0, v1.1.0].
    - Can only install one of: php-http/httplug[v1.1.0, v2.0.0].
    - Can only install one of: php-http/httplug[v1.1.0, v2.0.0].
    - Conclusion: install php-http/httplug v1.1.0|install sentry/sentry-laravel 1.0.0|install sentry/sentry-laravel 1.0.1|install sentry/sentry-laravel 1.0.x-dev


Installation failed, reverting ./composer.json to its original content.

Can you get us the output of composer why-not sentry/sentry-laravel ^1.0?

Also, we suspect that the root cause of this issue is in the fact that you're still getting the sentry/sdk metapackage. If you're manually requiring the packages to override the transports with something of your choice, I would suggest to you to override sentry/sdk. To do that, add this to your composer.json:

    "replace": {
        "sentry/sdk": "^2.0"
    },

This should avoid installing that metapackage. Please report back on those attempts.

@Bolandish alternatively we just bumped the curl client dependency in sentry/sdk so "just" composer require sentry/sentry-laravel:^1.0 should work now without any additional changes or packages needed.

@stayallive This happening when I update composer. Any thoughts?

image

Ī» composer require sentry/sentry-laravel
Using version ^1.0 for sentry/sentry-laravel
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover

In ClassDiscovery.php line 210:

  Unexpected exception when instantiating class.


In Psr17FactoryDiscovery.php line 22:

  No PSR-17 response factory found. Install a package from this list: https://packagist.org/providers/psr/http-factory-implementation


In DiscoveryFailedException.php line 41:

  Could not find resource using any discovery strategy. Find more information at http://docs.php-http.org/en/latest/discovery.html#common-errors
   - Puli Factory is not available
   - No valid candidate found using strategy "Http\Discovery\Strategy\CommonClassesStrategy". We tested the following candidates: .
   - No valid candidate found using strategy "Http\Discovery\Strategy\CommonPsr17ClassesStrategy". We tested the following candidates: Nyholm\Psr7\Factory\Psr17Factory, Zend\Diactoros\ResponseFactory, Http\Factory\Diactoros\ResponseFacto
  ry, Http\Factory\Guzzle\ResponseFactory, Http\Factory\Slim\ResponseFactory.


ocramius/package-versions:  Generating version class...
ocramius/package-versions: ...done generating version class
> Illuminate\Foundation\ComposerScripts::postUpdate
> php artisan ide-helper:generate

In ClassDiscovery.php line 210:

  Unexpected exception when instantiating class.


In Psr17FactoryDiscovery.php line 22:

  No PSR-17 response factory found. Install a package from this list: https://packagist.org/providers/psr/http-factory-implementation


In DiscoveryFailedException.php line 41:

  Could not find resource using any discovery strategy. Find more information at http://docs.php-http.org/en/latest/discovery.html#common-errors
   - Puli Factory is not available
   - No valid candidate found using strategy "Http\Discovery\Strategy\CommonClassesStrategy". We tested the following candidates: .
   - No valid candidate found using strategy "Http\Discovery\Strategy\CommonPsr17ClassesStrategy". We tested the following candidates: Nyholm\Psr7\Factory\Psr17Factory, Zend\Diactoros\ResponseFactory, Http\Factory\Diactoros\ResponseFacto
  ry, Http\Factory\Guzzle\ResponseFactory, Http\Factory\Slim\ResponseFactory.


> php artisan ide-helper:meta

In ClassDiscovery.php line 210:

  Unexpected exception when instantiating class.


In Psr17FactoryDiscovery.php line 22:

  No PSR-17 response factory found. Install a package from this list: https://packagist.org/providers/psr/http-factory-implementation


In DiscoveryFailedException.php line 41:

  Could not find resource using any discovery strategy. Find more information at http://docs.php-http.org/en/latest/discovery.html#common-errors
   - Puli Factory is not available
   - No valid candidate found using strategy "Http\Discovery\Strategy\CommonClassesStrategy". We tested the following candidates: .
   - No valid candidate found using strategy "Http\Discovery\Strategy\CommonPsr17ClassesStrategy". We tested the following candidates: Nyholm\Psr7\Factory\Psr17Factory, Zend\Diactoros\ResponseFactory, Http\Factory\Diactoros\ResponseFacto
  ry, Http\Factory\Guzzle\ResponseFactory, Http\Factory\Slim\ResponseFactory.

@Otienoh I have no idea what you have in your composer.json, if you could post that it would help figuring it out. But just the following is enough to get a working setup (default Laravel packages + sentry/sentry-laravel).

    "require": {
        "php": "^7.1.3",
        "fideloper/proxy": "^4.0",
        "laravel/framework": "5.7.*",
        "laravel/tinker": "^1.0",
        "sentry/sentry-laravel": "^1.0"
    },

Yeah, Fixed my issue with a note on the docs at the very last section. @stayallive Good job on the doc update

image

@Otienoh I don't think you understand what that does. If you added that to your composer.json it will effectively prevent Sentry from loading unless you add it yourself to config/app.php in the providers section. So Sentry wil not capture anything.

Please share your composer.json if possible so we can investigate why a suitable transport cannot be found.

Please share your composer.json if possible so we can investigate why a suitable transport cannot be found.

I believe that the reason (if he did what @Jean85 suggested) is that by telling Composer to not install sentry/sdk (the metapackage) then obviously each dependency of the core package must be required manually, which means a HTTP transport compatible with HTTPlug and a PSR-7 package

I don't know if it's completely related but i'm trying to install it and i'm getting this error:

Problem 1
    - Conclusion: don't install sentry/sentry-laravel 1.0.1
    - Conclusion: don't install sentry/sentry-laravel 1.0.0
    - sentry/sentry-laravel 1.0.0-beta4 requires sentry/sentry 2.0.0-beta2 -> satisfiable by sentry/sentry[2.0.0-beta2].
    - sentry/sentry-laravel 1.0.0-beta5 requires sentry/sentry 2.0.0-beta2 -> satisfiable by sentry/sentry[2.0.0-beta2].
    - Conclusion: don't install sentry/sentry 2.0.0-beta2
    - sentry/sentry-laravel 1.0.0-beta1 requires sentry/sentry 2.0.0-beta1 -> satisfiable by sentry/sentry[2.0.0-beta1].
    - sentry/sentry-laravel 1.0.0-beta2 requires sentry/sentry 2.0.0-beta1 -> satisfiable by sentry/sentry[2.0.0-beta1].
    - sentry/sentry-laravel 1.0.0-beta3 requires sentry/sentry 2.0.0-beta1 -> satisfiable by sentry/sentry[2.0.0-beta1].
    - Conclusion: don't install sentry/sentry 2.0.0-beta1
    - Conclusion: remove sentry/sentry 1.10.0
    - Installation request for sentry/sentry-laravel ^1.0 -> satisfiable by sentry/sentry-laravel[1.0.0, 1.0.0-beta1, 1.0.0-beta2, 1.0.0-beta3, 1.0.0-beta4, 1.0.0-beta5, 1.0.1, 1.0.x-dev].
    - Conclusion: don't install sentry/sentry 1.10.0
    - sentry/sentry-laravel 1.0.x-dev requires sentry/sdk ^2.0 -> satisfiable by sentry/sdk[2.0.0, 2.0.1, 2.0.2].
    - sentry/sdk 2.0.0 requires sentry/sentry ^2.0 -> satisfiable by sentry/sentry[2.0.0, 2.0.0-beta1, 2.0.0-beta2, 2.0.1, 2.0.x-dev].
    - sentry/sdk 2.0.1 requires sentry/sentry ^2.0 -> satisfiable by sentry/sentry[2.0.0, 2.0.0-beta1, 2.0.0-beta2, 2.0.1, 2.0.x-dev].
    - sentry/sdk 2.0.2 requires sentry/sentry ^2.0.1 -> satisfiable by sentry/sentry[2.0.1, 2.0.x-dev].
    - Can only install one of: sentry/sentry[2.0.0, 1.10.0].
    - Can only install one of: sentry/sentry[2.0.1, 1.10.0].
    - Can only install one of: sentry/sentry[2.0.x-dev, 1.10.0].
    - Installation request for sentry/sentry (locked at 1.10.0) -> satisfiable by sentry/sentry[1.10.0].

According to the last line of the Composer output it seems that you already have sentry/sentry installed and that is locked at version 1.x. I don't know which command you are using to update the package, but I would try to remove first the sentry/sentry package and then require sentry/sdk. Let us know if it works

Weird because i didn't have sentry/sentry in my composer.json. I had to run composer remove before requiring again the updated version. It worked now.

It's correct that you don't have it if you used to use sentry/sentry-laravel since it's a direct dependency of that package and gets installed automatically :wink:

Yeah decided to do it manually to prevent a block will try again next week

Also getting the same when I run install on my server:

"require": {
        "php": ">=7.2",
        "davejamesmiller/laravel-breadcrumbs": "5.x",
        "doctrine/dbal": "^2.9",
        "fideloper/proxy": "~4.0",
        "fzaninotto/faker": "~1.4",
        "guzzlehttp/psr7": "^1.5",
        "igaster/laravel-theme": "^2.0",
        "laravel/cashier": "~9.0",
        "laravel/framework": "5.7",
        "laravel/passport": "^4.0",
        "laravel/tinker": "~1.0",
        "league/flysystem-aws-s3-v3": "~1.0",
        "league/flysystem-cached-adapter": "~1.0",
        "owen-it/laravel-auditing": "^8.0",
        "php-http/curl-client": "^2.0",
        "sentry/sentry-laravel": "^1.0.1",
        "spatie/laravel-permission": "^2.12",
        "spatie/laravel-sluggable": "^2.1"
    },
    "require-dev": {
        "behat/behat": "^3.3",
        "behat/mink": "^1.7",
        "behat/mink-extension": "^2.2",
        "behat/mink-selenium2-driver": "^1.3",
        "friendsofphp/php-cs-fixer": "^2.4",
        "squizlabs/php_codesniffer": "^3.0",
        "fzaninotto/faker": "~1.4",
        "mockery/mockery": "0.9.*",
        "phpunit/phpunit": "~5.7"
    },
    "autoload": {
        "classmap": [
            "database"
        ],
        "psr-4": {
            "App\\": "app/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\\": "tests/",
            "Features\\": "features/"
        }
    },
    "scripts": {
        "post-root-package-install": [
            "php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "php artisan key:generate"
        ],
        "post-install-cmd": [
            "Illuminate\\Foundation\\ComposerScripts::postInstall"
        ],
        "post-update-cmd": [
            "Illuminate\\Foundation\\ComposerScripts::postUpdate"
        ]
    },
    "config": {
        "preferred-install": "dist",
        "sort-packages": true
    },
    "extra": {
        "laravel": {
            "dont-discover": ["sentry/sentry-laravel"]
        }
    }

@adamcopley try running composer update first, we recently updated our dependencies to allow for the 2.0 of the httplug CURL client and I just tried your dependencies and they install correctly without issues.

@stayallive We're also experiencing this - have tried a rm -rf vendor with a full composer update/install combo.

This is all our packages

 "require": {
        "php": "^7.1.3",
        "ext-json": "*",
        "algolia/algoliasearch-client-php": "^1.25",
        "backpack/crud": "^3.4",
        "backpack/logmanager": "^2.3",
        "backpack/permissionmanager": "^2.1",
        "chelout/laravel-relationship-events": "^1.0",
        "danielstjules/stringy": "^3.1",
        "fideloper/proxy": "^4.0",
        "genealabs/laravel-model-caching": "^0.4",
        "guzzlehttp/guzzle": "^6.3",
        "jgrossi/corcel": "^2.8",
        "jrean/laravel-user-verification": "^7.0",
        "laravel/framework": "5.8.*",
        "laravel/horizon": "^1.2",
        "laravel/passport": "^6.0",
        "laravel/scout": "^4.0",
        "laravel/socialite": "^4.0",
        "laravel/tinker": "^1.0",
        "league/csv": "^8.0",
        "mihaeu/html-formatter": "^1.0",
        "owen-it/laravel-auditing": "^9.0",
        "owenmelbz/domain-enforcement": "^0.0.6",
        "owenmelbz/laravel-stubs": "^0.0.5",
        "owenmelbz/vue-impersonate": "^0.0.5",
        "paragonie/csp-builder": "^2.3",
        "phpoffice/phpspreadsheet": "^1.6",
        "pragmarx/firewall": "^2.2",
        "predis/predis": "^1.1",
        "schuppo/password-strength": "^1.11",
        "sentry/sentry-laravel": "^1.0",
        "squizlabs/php_codesniffer": "^3.2",
        "symfony/css-selector": "^4.1",
        "symfony/dom-crawler": "^4.0",
        "tightenco/ziggy": "^0.6.6",
        "unicodeveloper/laravel-password": "^1.0",
        "whichbrowser/parser": "^2.0",
        "worldpay/worldpay-lib-php": "^2.1",
        "yadahan/laravel-authentication-log": "^1.2"
    },

These are the sentry packages that have got installed

laravel/framework                     v5.8.7             The Laravel Framework.
sentry/sdk                            2.0.2              This is a metapackage shipping sentry/sentry with a recommended http...
sentry/sentry                         2.0.1              A PHP SDK for Sentry (http://sentry.io)
sentry/sentry-laravel                 1.0.1              Laravel SDK for Sentry (https://sentry.io)

Getting the same No PSR-17 response factory found error

@OwenMelbz very interesting, seems like we might have messed up something somewhere.

Thanks everyone for sharing your composer.json, we are investigating this!

So it looks like there is some sort of incompatibility that composer for some reason is not complaining about (that we believe should be happening).

The problem is that you guys are using laravel/passport that requires zendframework/zend-diactoros:^1.0 but also requiring the php-http/curl-client:^2.0 (directly or indirectly) which requires zendframework/zend-diactoros:^2.0 (or another package that implements the PSR-17 response factory).

There are 2 solutions.

  • Upgrade laravel/passport to ^7.2.2 which allows for the correct zendframework/zend-diactoros:^2.0 to be installed
  • Downgrade/install php-http/curl-client:^1.0

We are seeing if there is something we can do from our side or we might be doing it wrong or there is a problem in the dependencies of httplug, but the above solutions should get you moving with using sentry/sentry-laravel:^1.0.

@stayallive thanks for looking into this, it’s really appreciated when product teams look out for their community, getting more rare these days with early dismissal of ā€œnot our problemā€.

Tomorrow I’ll try upgrading passport - this seems to make the most logical and progressive sense and shall report back :)

Update

Updating passport did solve it :) running laravel/passport 7.2.2

Although upgrading passport caused a strange mixture of errors and api endpoints not being authenticated properly so spend whole bunch of time fixing that :(

@OwenMelbz, thanks for your update! Keeping passport up-to-date is always a good thing (considering OAuth & security etc.), although the upgrade docs are very... non-existent which makes it a bit hard unfortunately.

We think we might have tracked down a way to fix this from our side or at least prevent it from happening in the future possibly. Will close this issue once we think we got it :)

For now happy to hear upgrading passport is a possible fix.

As updating passport was not an option atm, I was able to get reporting to work on Laravel 5.6 using composer require "sentry/sentry-laravel" "^0.11.0"

guys I dealt with this for 2 days and found out what helped me update to _laravel 5.8_:
if you don't have these then add

--> composer.json

in
"require": {
"sentry/sentry-laravel": "^0.1.0",
"sentry/sdk":"^2.0",
"illuminate/support":"5.8.*"

}
in
"require-dev": {
"orchestra/testbench": "3.8.*",
phpunit/phpunit: 7.5.

run :$composer update

This is wrong. sentry/sdk is not compatible with sentry/sentry-laravel < 1.0

so you mean it won't run or it will have some issues later? cause am pretty sure it did work for me !

It may run, but Sentry it's not working for sure.

"sentry/sentry-laravel": "^0.1.0" allows 0.1.0 and 0.1.1.

The first works with raven/raven, the deprecated lib, the second requires sentry/sentry with *, which is wrong; works at the Composer level, but the code will not.

I appreciate your explanation but I kinda got forced on this version of sentry/sentry cause once I put the recent one sentry/sentry :1.0.1 for example then sentry will stop working showing this error :
Call to undefined method Sentry\State\Hub::user_context()

Thanks

Just installed this package to run into the same issue.

Is updating laravel/passport still the best solution? I am using laravel/passport v7.0 at the moment.

In ClassDiscovery.php line 210:

  Unexpected exception when instantiating class.


In Psr17FactoryDiscovery.php line 22:

  No PSR-17 response factory found. Install a package from this list: https://packagist.org/providers/psr/http-factory-implementation


In DiscoveryFailedException.php line 41:

  Could not find resource using any discovery strategy. Find more information at http://docs.php-http.org/en/latest/discovery.html#comm
  on-errors
   - Puli Factory is not available
   - No valid candidate found using strategy "Http\Discovery\Strategy\CommonClassesStrategy". We tested the following candidates: .
   - No valid candidate found using strategy "Http\Discovery\Strategy\CommonPsr17ClassesStrategy". We tested the following candidates:
  Nyholm\Psr7\Factory\Psr17Factory, Zend\Diactoros\ResponseFactory, Http\Factory\Diactoros\ResponseFactory, Http\Factory\Guzzle\Respons
  eFactory, Http\Factory\Slim\ResponseFactory.

I suggested https://github.com/getsentry/sentry-php-sdk/pull/2 as a solution, so you can try to apply it indipendently requiring http-interop/http-factory-guzzle. In general, requiring any of the feasible package would fix the issue, since sentry/sdk is only used to require the suggested transport, but you're not forced to use those.

Running composer update worked fine for me, I don’t have an issue any more based on the above.

@Jean85 , sorry for the late response but after posting my question I uninstalled the sentry package, ran composer update, upgraded the laravel\passport, and then reinstalled sentry. Worked fine after that. I am using laravel version 5.7.

Thanks.

As seeing most if not all issues are resolved I am closing this.

In case there are still issues or problem please do open a _new_ issue so we can investigate further!

Thanks for everyone involved and having patience with us! šŸ˜„

Was this page helpful?
0 / 5 - 0 ratings