Skip to content

Remove xdebug installation - #35667

Closed
brylie wants to merge 2 commits into
WordPress:trunkfrom
brylie:patch-3
Closed

Remove xdebug installation#35667
brylie wants to merge 2 commits into
WordPress:trunkfrom
brylie:patch-3

Conversation

@brylie

@brylie brylie commented Oct 15, 2021

Copy link
Copy Markdown
Contributor

Removing Xdebug since it is already installed in the wordpress image.

Closes #34320

Description

The @wordpress/env Docker image is having recurring issues when trying to install Xdebug, as outlined in #34320. While discussing the Xdebug errors, we discovered that the wordpress image, used by @wordpress/env already contains Xdebug. Hence, the installation errors observed in issue #34320

image

This pull request removes the conflicting Xdebug installation.

How has this been tested?

Screenshots

Types of changes

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • I've tested my changes with keyboard and screen readers.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR (please manually search all *.native.js files for terms that need renaming or removal).
Removing Xdebug since it is already installed in the `wordpress` image.

Closes #34320
@ZebulanStanphill ZebulanStanphill added [Tool] Env /packages/env [Type] Bug An existing feature does not function as intended labels Oct 15, 2021
@brylie

brylie commented Oct 27, 2021

Copy link
Copy Markdown
Contributor Author

@noahtallen, would you please review this pull request? It fixes issue #34320, which has repeatedly blocked development and deployment.

image

The underlying issue is that the xdebug package is already installed in the wordpress image so causes errors when wp-env tries to install it downstream.

@noahtallen

noahtallen commented Oct 27, 2021

Copy link
Copy Markdown
Member

@brylie Thanks for the contribution, and I'm sorry for the pain this is causing.

What if we instead used this code:

- RUN pecl install xdebug && docker-php-ext-enable xdebug
+ RUN if [ -z "$(pecl list | grep xdebug)" ] ; then pecl install xdebug ; fi
+ RUN docker-php-ext-enable xdebug

Here's my testing results via npx wp-env run wordpress bash:

# If the package exists, it will not attempt to install xdebug and exits with 0
root@bbf41d59e0c0:/var/www/html# if [ -z "$(pecl list | grep xdebug)" ] ; then pecl install xdebug ; fi
root@bbf41d59e0c0:/var/www/html# echo $?
0

# If the package does not exist, it will attempt to install xdebug. This will obviously work in general, but demonstrates that pecl is getting executed.
root@bbf41d59e0c0:/var/www/html# if [ -z "$(pecl list | grep foo)" ] ; then pecl install xdebug ; fi
pecl/xdebug is already installed and is the same as the released version 3.1.1
install failed
root@bbf41d59e0c0:/var/www/html# echo $?
1

# We can run docker-php-ext-enable without getting an exit code of 1
root@bbf41d59e0c0:/var/www/html# docker-php-ext-enable xdebug

warning: xdebug (xdebug) is already loaded!

root@bbf41d59e0c0:/var/www/html# echo $?
0

This should prevent it from crashing in the scenario you're getting

My two concerns with this PR are:

  1. It's a breaking change, and I expect existing setups with working xdebug would break.
  2. wp-env is working okay for a lot of people. I can't replicate the error unfortunately, so I'm cautious about relying on the base wordpress image. Why is install not failing for every instance of wp-env if xdebug always exists in the base image?

That's why I think fixing the error in question would be a safer approach for the time being, and hopefully get everything working for you!

I will also take a look at your PR conditionally installing Xdebug, since I agree that is a better approach in general.

@brylie

brylie commented Oct 28, 2021

Copy link
Copy Markdown
Contributor Author

Sure, the fix sounds reasonable.

I am encountering this issue when switching between projects that use wp-env where wo-env may not have been stopped properly in one project. Similarly, when introducing a syntax error in a project with wo-env that causes the container build to fail subsequently running wp-env start will produce the error. These are both circumstances where the wordpress service remains in-tact and seems to be shared across projects/builds.

@brylie

brylie commented Oct 28, 2021

Copy link
Copy Markdown
Contributor Author

What if we instead used this code:

RUN if [ -z "$(pecl list | grep xdebug)" ] ; then pecl install xdebug ; fi
RUN docker-php-ext-enable xdebug

@noahtallen I'll close this pull request as I've incorporated your suggestion(s) into PR #34324

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Tool] Env /packages/env [Type] Bug An existing feature does not function as intended

3 participants