Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shipped Guzzle client causes dependency hell #542

Closed
ChristophWurst opened this issue Aug 6, 2018 · 11 comments · Fixed by #559
Closed

Shipped Guzzle client causes dependency hell #542

ChristophWurst opened this issue Aug 6, 2018 · 11 comments · Fixed by #559

Comments

@ChristophWurst
Copy link
Member

ChristophWurst commented Aug 6, 2018

Steps to reproduce

  1. Install this app.
  2. Use an app that uses the IClientService.
  3. client->get(…).

Expected behaviour

Have a working http client.

Actual behaviour

💥

Server configuration

Nextcloud version:

14.0.0 Beta 2

Bookmarks version:

master

Logs

{
  "reqId": "aSE9z41mGwcRfxSWGPLQ",
  "level": 3,
  "time": "2018-08-06T04:46:51+00:00",
  "remoteAddr": "127.0.0.1",
  "user": "admin",
  "app": "index",
  "method": "GET",
  "url": "\/apps\/mail\/api\/avatars\/url\/mailer@neuronation.com",
  "message": {
    "Exception": "Error",
    "Message": "Call to undefined method GuzzleHttp\\Client::request()",
    "Code": 0,
    "Trace": [
      {
        "file": "\/home\/christoph\/workspace\/nextcloud\/apps\/mail\/lib\/Service\/Avatar\/GravatarSource.php",
        "line": 61,
        "function": "get",
        "class": "OC\\Http\\Client\\Client",
        "type": "->",
        "args": [
          "https:\/\/secure.gravatar.com\/avatar\/66dc6e6b7970f5988ea44bc4f9674b57?size=128&d=404"
        ]
      },
      {
        "file": "\/home\/christoph\/workspace\/nextcloud\/apps\/mail\/lib\/Service\/Avatar\/CompositeAvatarSource.php",
        "line": 61,
        "function": "fetch",
        "class": "OCA\\Mail\\Service\\Avatar\\GravatarSource",
        "type": "->",
        "args": [
          "mailer@neuronation.com",
          {
            "__class__": "OCA\\Mail\\Service\\Avatar\\AvatarFactory"
          }
        ]
      },
      {
        "file": "\/home\/christoph\/workspace\/nextcloud\/apps\/mail\/lib\/Service\/AvatarService.php",
        "line": 114,
        "function": "fetch",
        "class": "OCA\\Mail\\Service\\Avatar\\CompositeAvatarSource",
        "type": "->",
        "args": [
          "mailer@neuronation.com",
          {
            "__class__": "OCA\\Mail\\Service\\Avatar\\AvatarFactory"
          },
          true
        ]
      },
      {
        "file": "\/home\/christoph\/workspace\/nextcloud\/apps\/mail\/lib\/Controller\/AvatarsController.php",
        "line": 75,
        "function": "getAvatar",
        "class": "OCA\\Mail\\Service\\AvatarService",
        "type": "->",
        "args": [
          "mailer@neuronation.com",
          "admin"
        ]
      },
      {
        "file": "\/home\/christoph\/workspace\/nextcloud\/lib\/private\/AppFramework\/Http\/Dispatcher.php",
        "line": 166,
        "function": "url",
        "class": "OCA\\Mail\\Controller\\AvatarsController",
        "type": "->",
        "args": [
          "mailer@neuronation.com"
        ]
      },
      {
        "file": "\/home\/christoph\/workspace\/nextcloud\/lib\/private\/AppFramework\/Http\/Dispatcher.php",
        "line": 99,
        "function": "executeController",
        "class": "OC\\AppFramework\\Http\\Dispatcher",
        "type": "->",
        "args": [
          {
            "__class__": "OCA\\Mail\\Controller\\AvatarsController"
          },
          "url"
        ]
      },
      {
        "file": "\/home\/christoph\/workspace\/nextcloud\/lib\/private\/AppFramework\/App.php",
        "line": 118,
        "function": "dispatch",
        "class": "OC\\AppFramework\\Http\\Dispatcher",
        "type": "->",
        "args": [
          {
            "__class__": "OCA\\Mail\\Controller\\AvatarsController"
          },
          "url"
        ]
      },
      {
        "file": "\/home\/christoph\/workspace\/nextcloud\/lib\/private\/AppFramework\/Routing\/RouteActionHandler.php",
        "line": 47,
        "function": "main",
        "class": "OC\\AppFramework\\App",
        "type": "::",
        "args": [
          "OCA\\Mail\\Controller\\AvatarsController",
          "url",
          {
            "__class__": "OC\\AppFramework\\DependencyInjection\\DIContainer"
          },
          {
            "email": "mailer@neuronation.com",
            "_route": "mail.avatars.url"
          }
        ]
      },
      {
        "function": "__invoke",
        "class": "OC\\AppFramework\\Routing\\RouteActionHandler",
        "type": "->",
        "args": [
          {
            "email": "mailer@neuronation.com",
            "_route": "mail.avatars.url"
          }
        ]
      },
      {
        "file": "\/home\/christoph\/workspace\/nextcloud\/lib\/private\/Route\/Router.php",
        "line": 297,
        "function": "call_user_func",
        "args": [
          {
            "__class__": "OC\\AppFramework\\Routing\\RouteActionHandler"
          },
          {
            "email": "mailer@neuronation.com",
            "_route": "mail.avatars.url"
          }
        ]
      },
      {
        "file": "\/home\/christoph\/workspace\/nextcloud\/lib\/base.php",
        "line": 989,
        "function": "match",
        "class": "OC\\Route\\Router",
        "type": "->",
        "args": [
          "\/apps\/mail\/api\/avatars\/url\/mailer@neuronation.com"
        ]
      },
      {
        "file": "\/home\/christoph\/workspace\/nextcloud\/index.php",
        "line": 42,
        "function": "handleRequest",
        "class": "OC",
        "type": "::",
        "args": [
          
        ]
      }
    ],
    "File": "\/home\/christoph\/workspace\/nextcloud\/lib\/private\/Http\/Client\/Client.php",
    "Line": 161,
    "CustomMessage": "--"
  },
  "userAgent": "Mozilla\/5.0 (X11; Linux x86_64; rv:61.0) Gecko\/20100101 Firefox\/61.0",
  "version": "14.0.0.14"
}


cc @skjnldsv because you originally reported this to me. Welcome to the php dependency hell 😈

@ChristophWurst
Copy link
Member Author

Guzzle isn't a direct dependency of this app, though: https://github.com/nextcloud/bookmarks/blob/master/composer.json

$ composer why guzzlehttp/guzzle
marcelklehr/link-preview  v2.0.6  requires  guzzlehttp/guzzle (^5.3)  
wnx/screeenly-client      v1.0.0  requires  guzzlehttp/guzzle (~5)

@marcelklehr
Copy link
Member

marcelklehr commented Aug 6, 2018

Ah, I explicitly used libs that depended on guzzle 5 in order to be able to use them in nextcloud. When was Guzzle v6 introduced in nextcloud? It would be nice to be able to still use the app in v13

@ChristophWurst
Copy link
Member Author

When was Guzzle v6 introduced in nextcloud?

nextcloud/3rdparty#83.

Generally speaking, I would say duplicate libraries should be avoided at any price, simply because code becomes completely unpredictable otherwise as the actually loaded class depends on the enabled apps and the order of the autoloader registration. cc @rullzer

@ChristophWurst
Copy link
Member Author

It would be nice to be able to still use the app in v13

With the visual restructuring required for nc14, I'm afraid this could be a challenge.

@rullzer
Copy link
Member

rullzer commented Aug 7, 2018

Best would be:

  • Create a final release for 13 now and branch off
  • Create a new release for 14 without guzzle

@marcelklehr
Copy link
Member

sigh Long live PHP 🎉

@rullzer Sounds good.

@xf-
Copy link

xf- commented Aug 27, 2018

0.12.x breaks nextcloud v14 RC1 because of guzzlehttp

@weeman1337
Copy link
Member

It's an interesting discussion here. Does that mean app devs shouldn't use any indirect dependency in an app that is also somehow in 3rdparty? :(

In this specific case perhaps it makes sense updating the bookmarks dependencies, as their current versions rely on guzzle 6 instead of 5. @rullzer what do you think?

@marcelklehr
Copy link
Member

In the future, it would be cool if core could provide a client that follows e.g. the psr-18 spec, so interoperability is maintained.

@marcelklehr
Copy link
Member

@weeman1337

It's an interesting discussion here. Does that mean app devs shouldn't use any indirect dependency in an app that is also somehow in 3rdparty? :(

That's probably advisable.

@marcelklehr
Copy link
Member

Bookmarks v0.13 is released with Nc 14 support

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

5 participants