coenjacobs / mozart

Developers tool for WordPress plugins: Wraps all your projects dependencies in your own namespace, in order to prevent conflicts with other plugins loading the same dependencies in different versions.
https://coenjacobs.me/projects/mozart/
MIT License
432 stars 55 forks source link

Issues with rubix/ml #48

Open ChristophWurst opened 4 years ago

ChristophWurst commented 4 years ago

Hi again,

I have another lib that causes trouble. It's rubix/ml. The installation fails with

> "vendor/bin/mozart" compose

In Filesystem.php line 405:

  File already exists at path: lib/Vendor/JAMA/Matrix.php

when it tries to write https://github.com/ChristophWurst/rubix-ml-mozart/blob/master/lib/Vendor/JAMA/Matrix.php. I tried the override_autoloader like in the readme (https://github.com/ChristophWurst/rubix-ml-mozart/commit/597515eefb9070ea49e3d85f0164338b969e2b79) but that will lead to incorrect namespaces on the array_transpose function.

I'm a bit lost with where to look or what to debug. I'd be grateful for any help or pointers :pray:

Cheers

ChristophWurst commented 4 years ago

Btw https://github.com/ChristophWurst/rubix-ml-mozart was created to showcase this issue. You should be able to clone and reproduce the error.

coenjacobs commented 4 years ago

Hi @ChristophWurst, I need to take a proper look at your showcase repository. Thanks for setting that up. Just wanted to let you know that I'm looking at it and not simply ignoring your issue. 😄

ChristophWurst commented 4 years ago

No worries and take your time. This is not a pressing for us and we're using your lib for free after all :wink:

If there is anything I can help with please let me know :pray:

Mozart is quite a game changer for us at Nextcloud, btw, as we suffer form the same conflict problem Wordpress faces https://blog.wuc.me/2020/05/13/rock-me-amadeus-php-dependency-hell.html.

ChristophWurst commented 4 years ago

I wanted to give this another shot as we have to move forward with our app. So I updated the dependencies in https://github.com/ChristophWurst/rubix-ml-mozart, but it still gives me the exact same error. @coenjacobs do you have any ideas of where to start looking?

Edit: So I tried to attach a debugger and step through the code. Unfortunately that didn't enlighten me, I'm still struggling to understand the expected behavior vs what's happening right now.

BrianHenryIE commented 4 years ago

PR #63 addresses it :

{
    "name": "christophwurst/rubix-ml-mozart",
    "license": "MIT",
    "authors": [
        {
            "name": "Christoph Wurst",
            "email": "christoph@winzerhof-wurst.at"
        }
    ],
    "require": {
        "rubix/ml": "*"
    },
    "require-dev": {
        "coenjacobs/mozart": "dev-master",
        "cweagans/composer-patches": "~1.0"
    },
    "scripts": {
        "post-install-cmd": [
            "\"vendor/bin/mozart\" compose",
            "composer dump-autoload"
        ],
        "post-update-cmd": [
            "\"vendor/bin/mozart\" compose",
            "composer dump-autoload"
        ]
    },
    "extra": {
        "patches": {
            "coenjacobs/mozart": {
                "issue-48": "https://github.com/coenjacobs/mozart/pull/63.patch"
            }
        },
        "mozart": {
            "dep_namespace": "Test\\Vendor\\",
            "dep_directory": "/lib/Vendor/",
            "classmap_directory": "/lib/autoload/",
            "classmap_prefix": "TEST_",
            "delete_vendor_directories": false
        }
    }
}

but the PR with the fix fails the tests so can't be merged. I don't really have time to look at that now.

The issue was how processing the autoloader config was handling multiple namespaces in the same composer.json's PSR4 key, you can see that only one of the namespace names will survive the loop.

ChristophWurst commented 4 years ago

Awesome work @BrianHenryIE. Thanks a lot :raised_hands: