porozhnyy / laravel-roadrunner

Simple Laravel-Roadrunner bridge
MIT License
47 stars 5 forks source link

With --no-dev: Cannot instantiate abstract class roadrunner-worker:28 #2

Closed tekaeren closed 4 years ago

tekaeren commented 4 years ago

The worker works fine when installed by composer with development packages.

When packages installed with --no-dev the result is as follows:

time="2019-10-16T14:05:54Z" level=error msg="[http]: unable to connect to worker: [2019-10-16 15:05:54] production.ERROR: Cannot instantiate abstract class Zend\\Diactoros\\ServerRequestFactory {\"exception\":\"[object] (Symfony\\\\Component\\\\Debug\\\\Exception\\\\FatalThrowableError(code: 0): Cannot instantiate abstract class Zend\\\\Diactoros\\\\ServerRequestFactory at /app/vendor/hunternnm/laravel-roadrunner/bin/roadrunner-worker:28)\n[stacktrace]\n#0 {main}\n\"} \n"
time="2019-10-16T14:05:54Z" level=debug msg="[rpc]: stopped"
Error: [http]: unable to connect to worker: [2019-10-16 15:05:54] production.ERROR: Cannot instantiate abstract class Zend\Diactoros\ServerRequestFactory {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): Cannot instantiate abstract class Zend\\Diactoros\\ServerRequestFactory at /app/vendor/hunternnm/laravel-roadrunner/bin/roadrunner-worker:28)
[stacktrace]
#0 {main}
"}

Tried already with composer update and composer install after removing the composer.lock file.

Packages in revisions:

Installed with command: composer require --update-no-dev --no-suggest --prefer-dist --no-scripts --update-with-all-dependencies hunternnm/laravel-roadrunner "^2.0.2"\ && php artisan vendor:publish --provider="Hunternnm\LaravelRoadrunner\RoadrunnerServiceProvider" --tag=config. Installastion with dev-requirements does not start with environment set to production because of Dusk package.

porozhnyy commented 4 years ago

And how does roadrunner run? It seems to me that he can not find the file autoload.php

tekaeren commented 4 years ago

RR does not run, when the worker stops it exits too. Full log (from RR start to exit):

time="2019-10-16T14:34:51Z" level=debug msg="[rpc]: started"
time="2019-10-16T14:34:51Z" level=debug msg="[http]: started"
time="2019-10-16T14:34:51Z" level=error msg="[http]: unable to connect to worker: [2019-10-16 15:34:51] production.ERROR: Cannot instantiate abstract class Zend\\Diactoros\\ServerRequestFactory {\"exception\":\"[object] (Symfony\\\\Component\\\\Debug\\\\Exception\\\\FatalThrowableError(code: 0): Cannot instantiate abstract class Zend\\\\Diactoros\\\\ServerRequestFactory at /app/vendor/hunternnm/laravel-roadrunner/bin/roadrunner-worker:28)\n[stacktrace]\n#0 {main}\n\"} \n"
time="2019-10-16T14:34:51Z" level=debug msg="[rpc]: stopped"
Error: [http]: unable to connect to worker: [2019-10-16 15:34:51] production.ERROR: Cannot instantiate abstract class Zend\Diactoros\ServerRequestFactory {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): Cannot instantiate abstract class Zend\\Diactoros\\ServerRequestFactory at /app/vendor/hunternnm/laravel-roadrunner/bin/roadrunner-worker:28)
[stacktrace]
#0 {main}
"}

I can run RR with another worker (https://github.com/avto-dev/roadrunner-laravel), but there I have issues with the session handling.

With laravel-roadrunner, RR runs when I build 'dev' reqquirements, and set environment to 'local'.

porozhnyy commented 4 years ago

Hmmm, can you show how you launch rr? Example: ./rr serve -d -v from project directory. It seems to me that your launch is not from the project directory and the script cannot find the autoload.php file. I install with --no-dev and all works fine. Also try starting from the project directory php vendor/hunternnm/laravel-roadrunner/bin/roadrunner-worker - it should not show the same error See an example, maybe it will help you https://github.com/Hunternnm/laravel-roadrunner-example

tekaeren commented 4 years ago

I'll start from the scratch. First problems occur while adding the package to project:

composer require --update-no-dev --no-suggest --prefer-dist --no-scripts --update-with-all-dependencies hunternnm/laravel-roadrunner "^2.0.2"    && php artisan vendor:publish --provider="Hunternnm\LaravelRoadrunner\RoadrunnerServiceProvider" --tag=config

    1/1:    http://repo.packagist.org/p/provider-latest$2a581730860e849e30e921fa2ffdbd4261a0581bd148308b618aece1f9d8b306.json
    Finished: success: 1, skipped: 0, failure: 0, total: 1
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for hunternnm/laravel-roadrunner ^2.0.2 -> satisfiable by hunternnm/laravel-roadrunner[v2.0.2].
    - Conclusion: remove symfony/psr-http-message-bridge v1.1.0
    - Conclusion: don't install symfony/psr-http-message-bridge v1.1.0
    - hunternnm/laravel-roadrunner v2.0.2 requires symfony/psr-http-message-bridge ^1.2 -> satisfiable by symfony/psr-http-message-bridge[1.2.x-dev, v1.2.0].
    - Can only install one of: symfony/psr-http-message-bridge[1.2.x-dev, v1.1.0].
    - Can only install one of: symfony/psr-http-message-bridge[v1.2.0, v1.1.0].
    - Installation request for symfony/psr-http-message-bridge (locked at v1.1.0) -> satisfiable by symfony/psr-http-message-bridge[v1.1.0].

Running update with --no-dev does not mean require-dev is ignored, it just means the packages will not be installed. If dev requirements are blocking the update you have to resolve those problems.

Installation failed, reverting ./composer.json to its original content.
The command '/bin/sh -c composer require --update-no-dev --no-suggest --prefer-dist --no-scripts --update-with-all-dependencies hunternnm/laravel-roadrunner "^2.0.2"    && php artisan vendor:publish --provider="Hunternnm\LaravelRoadrunner\RoadrunnerServiceProvider" --tag=config' returned a non-zero code: 2

This can be easily fix by adding the symfony/psr-http-message-bridge "1.2.0" before laravel-roadrunner, but still is strange since no real package collisions happens here.

Running rr from project dir:

root@56cb0aeed0b9:/app# pwd
/app
root@56cb0aeed0b9:/app# rr serve -d -vvv -c /app/.rr.yml
DEBU[0000] [metrics]: disabled
DEBU[0000] [headers]: disabled
DEBU[0000] [rpc]: started
DEBU[0000] [http]: started
ERRO[0000] [http]: unable to connect to worker: [2019-10-18 08:48:16] production.ERROR: Cannot instantiate abstract class Zend\Diactoros\ServerRequestFactory {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): Cannot instantiate abstract class Zend\\Diactoros\\ServerRequestFactory at /app/vendor/hunternnm/laravel-roadrunner/bin/roadrunner-worker:28)
[stacktrace]
#0 {main}
"}
DEBU[0000] [rpc]: stopped
Error: [http]: unable to connect to worker: [2019-10-18 08:48:16] production.ERROR: Cannot instantiate abstract class Zend\Diactoros\ServerRequestFactory {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): Cannot instantiate abstract class Zend\\Diactoros\\ServerRequestFactory at /app/vendor/hunternnm/laravel-roadrunner/bin/roadrunner-worker:28)
[stacktrace]
#0 {main}
"}

Running from project dir with workidir set:

root@56cb0aeed0b9:/app# rr serve -d -vvv -c /app/.rr.yml -w /app
DEBU[0000] [metrics]: disabled
DEBU[0000] [headers]: disabled
DEBU[0000] [rpc]: started
DEBU[0000] [http]: started
ERRO[0000] [http]: unable to connect to worker: [2019-10-18 08:50:11] production.ERROR: Cannot instantiate abstract class Zend\Diactoros\ServerRequestFactory {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): Cannot instantiate abstract class Zend\\Diactoros\\ServerRequestFactory at /app/vendor/hunternnm/laravel-roadrunner/bin/roadrunner-worker:28)
[stacktrace]
#0 {main}
"}
DEBU[0000] [rpc]: stopped
Error: [http]: unable to connect to worker: [2019-10-18 08:50:11] production.ERROR: Cannot instantiate abstract class Zend\Diactoros\ServerRequestFactory {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): Cannot instantiate abstract class Zend\\Diactoros\\ServerRequestFactory at /app/vendor/hunternnm/laravel-roadrunner/bin/roadrunner-worker:28)
[stacktrace]
#0 {main}"}

Running worker directly and same error:

root@56cb0aeed0b9:/app# php vendor/bin/roadrunner-worker
[2019-10-18 08:50:55] production.ERROR: Cannot instantiate abstract class Zend\Diactoros\ServerRequestFactory {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): Cannot instantiate abstract class Zend\\Diactoros\\ServerRequestFactory at /app/vendor/hunternnm/laravel-roadrunner/bin/roadrunner-worker:28)
[stacktrace]
#0 {main}
"}

In roadrunner-worker line 28:

  Cannot instantiate abstract class Zend\Diactoros\ServerRequestFactory
porozhnyy commented 4 years ago

You have a package symfony/psr-http-message-bridge version 1.10 fixed in the composer.json file. If you remove this dependence or upgrade it, your problem should go away

tekaeren commented 4 years ago

Hmm, it's not in the composer.json, but in lock file. I'll try adding the worker to composer.json and build dependencies without the lock file.

tekaeren commented 4 years ago

Adding laravel-roadrunner to composer.json, removing composer.lock fixes the dependencies error, but the main issue with Zend\Diactoros\ServerRequestFactory remains...

Composer file used:

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "require": {
        "php": "^7.1.3",
        "creitive/laravel5-breadcrumbs": "^2.0",
        "davebolger/laravel-csv": "dev-master",
        "doctrine/dbal": "^2.5",
        "elasticsearch/elasticsearch": "~6.0",
        "ellipsesynergie/api-response": "^0.15.0",
        "fideloper/proxy": "^4.0",
        "graham-campbell/flysystem": "^5.0",
        "guzzlehttp/guzzle": "~6.0",
        "intervention/image": "2.3.*",
        "intervention/imagecache": "2.3.*",
        "laracasts/utilities": "2.1.*",
        "laravel/framework": "5.6.*",
        "laravel/passport": "~5.0",
        "laravel/tinker": "^1.0",
        "laravelcollective/html": "5.6.*",
        "league/flysystem-sftp": "^1.0",
        "maatwebsite/excel": "~2.1.0",
        "mpociot/laravel-apidoc-generator": "^2.0",
        "pda/pheanstalk": "~3.0",
        "rollbar/rollbar-laravel": "^4.0",
        "torann/hashids": "2.0.*@dev",
        "hunternnm/laravel-roadrunner": "^2.0.2"
    },
    "require-dev": {
        "fzaninotto/faker": "^1.7",,
        "barryvdh/laravel-debugbar": "^3.1"
        "laravel/dusk": "^3.0",
        "laravel/homestead": "^7",
        "mockery/mockery": "^1.0",
        "nunomaduro/collision": "^2.0",
        "phpunit/phpunit": "^7.0"
    },
    "repositories": [
        {
            "type": "vcs",
            "url":  "https://github.com/davebolger/laravel-csv/"
        }
    ],
    "autoload": {
        "classmap": [
            "database/seeds",
            "database/factories"
        ],
        "psr-4": {
            "App\\": "app/"
        },
        "files": [
            "app/Helpers/app-functions.php",
            "app/Helpers/template-functions.php"
        ]
    },
    "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
}
porozhnyy commented 4 years ago

@tekaeren I will get to my computer in a few hours and check with your dependencies

tarampampam commented 4 years ago

Seems like

"require": {
    "zendframework/zend-diactoros": "^2"
},

must be added into dependencies list

tekaeren commented 4 years ago

In the end I had to get back to pure laravel engine - legacy code did not handle redirections correctly.