Skip to content

Cannot redeclare React\Promise\resolve() #23

Closed

Description

@schmunk42

Hi,

we stumbled over this issue today:

PHP Fatal error:  Cannot redeclare React\Promise\resolve() (previously declared in /root/.composer/vendor/react/promise/src/functions.php:5) in /app/vendor/react/promise/src/React/Promise/functions.php on line 12
PHP Fatal error:  Cannot redeclare React\Promise\resolve() (previously declared in /root/.composer/vendor/react/promise/src/functions.php:5) in /app/vendor/react/promise/src/React/Promise/functions.php on line 12
[...]

We have a composer packages installed globally and per project which both depend on react/promise.

I think the composer autoloader always loads the file specified here which looks to me like the source of the error.

I don't know if composer should handle that...

You could wrap the definitions in a function_exists() call if you have to use the legacy files autoloading.

Activity

  1. jsor commented on Dec 2, 2014

    @jsor
    Member

    Autoloading via files isn't by any means deprecated and currently the only way to load functions. You should define your dependencies explicitely in your composer.json per project and don't rely on global packages (and I can't think of any reason why you should do that).

  2. schmunk42 commented on Dec 2, 2014

    @schmunk42
    Author

    Autoloading via files isn't by any means deprecated and currently the only way to load functions.

    Yeah, sorry. I never saw the function loading before, but I also thought that this is the only way in the end.

    You should define your dependencies explicitely in your composer.json per project and don't rely on global packages (and I can't think of any reason why you should do that).

    The problem is, that I have the dependency defined in a dependency - I do not have control about it.

    I didn't track it down 100%, but in my case I have Codeception (testing-suite) installed globally, just because it is rather large and takes a while to install.

    Other issues might come from composer plugins, which have to be installed globally. This would be related to composer/composer#3082

    ...

    There's already an issue about it in composer composer/composer#3003

    And guzzle had something similar guzzle/guzzle#676. They solved it with an if statement ;). But for sure it would be better to have the fix in composer.

  3. added a commit that references this issue on Dec 3, 2014
    586f208
  4. bhajan903 commented on Apr 9, 2020

    @bhajan903

    hey ,
    how solved this
    "Sorry, that didn’t work.
    Please try again or come back later.
    500 Error. Internal Server Error."
    please!

  5. WyriHaximus commented on Apr 18, 2020

    @WyriHaximus
    Member

    @bhajan903 check your server logs, that error is so generic we can't do anything with it. Also please open a new ticket for if the error is ReactPHP related.

  6. added this to the v2.2 milestone on Jun 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions