Skip to content

Cannot redeclare React\Promise\resolve() #23

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

Closed
schmunk42 opened this issue Dec 2, 2014 · 4 comments · Fixed by #25
Closed

Cannot redeclare React\Promise\resolve() #23

schmunk42 opened this issue Dec 2, 2014 · 4 comments · Fixed by #25
Milestone

Comments

@schmunk42
Copy link

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.

@jsor
Copy link
Member

jsor commented Dec 2, 2014

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

@schmunk42
Copy link
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.

@bhajan903
Copy link

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

@WyriHaximus
Copy link
Member

WyriHaximus commented Apr 18, 2020

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

@clue clue added this to the v2.2 milestone Jun 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants