Bookmarks: Shipped `Guzzle` client causes dependency hell

Created on 6 Aug 2018  Â·  11Comments  Â·  Source: nextcloud/bookmarks

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

:boom:

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\/[email protected]",
  "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": [
          "[email protected]",
          {
            "__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": [
          "[email protected]",
          {
            "__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": [
          "[email protected]",
          "admin"
        ]
      },
      {
        "file": "\/home\/christoph\/workspace\/nextcloud\/lib\/private\/AppFramework\/Http\/Dispatcher.php",
        "line": 166,
        "function": "url",
        "class": "OCA\\Mail\\Controller\\AvatarsController",
        "type": "->",
        "args": [
          "[email protected]"
        ]
      },
      {
        "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": "[email protected]",
            "_route": "mail.avatars.url"
          }
        ]
      },
      {
        "function": "__invoke",
        "class": "OC\\AppFramework\\Routing\\RouteActionHandler",
        "type": "->",
        "args": [
          {
            "email": "[email protected]",
            "_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": "[email protected]",
            "_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\/[email protected]"
        ]
      },
      {
        "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 :smiling_imp:

Most helpful comment

Best would be:

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

All 11 comments

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)

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

When was Guzzle v6 introduced in nextcloud?

https://github.com/nextcloud/3rdparty/pull/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

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.

Best would be:

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

sigh Long live PHP :tada:

@rullzer Sounds good.

0.12.x breaks nextcloud v14 RC1 because of guzzlehttp

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?

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.

@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.

Bookmarks v0.13 is released with Nc 14 support

Was this page helpful?
0 / 5 - 0 ratings

Related issues

homelessgamer picture homelessgamer  Â·  6Comments

marcelklehr picture marcelklehr  Â·  4Comments

bspire picture bspire  Â·  4Comments

marcelklehr picture marcelklehr  Â·  4Comments

simonspa picture simonspa  Â·  4Comments