Skip to content
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

Disable Xdebug by default unless specified by user #34324

Merged
merged 13 commits into from
Oct 29, 2021
Merged

Disable Xdebug by default unless specified by user #34324

merged 13 commits into from
Oct 29, 2021

Conversation

brylie
Copy link
Contributor

@brylie brylie commented Aug 26, 2021

Description

Currently, wp-env installs Xdebug regardless of whether the user has requested it. The only installation check is based on PHP version being 7.2+.

Xdebug shouldn't be installed unless specified by the user. Likewise, the Docker file should be more careful when running the pecl install xdebug command, as noted by @noahtallen.

The added complexity of the Xdebug installation is causing some other issues:

How has this been tested?

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

@brylie brylie requested a review from noahtallen as a code owner August 26, 2021 09:44
@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Aug 26, 2021
@github-actions
Copy link

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @brylie! In case you missed it, we'd love to have you join us in our Slack community, where we hold regularly weekly meetings open to anyone to coordinate with each other.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

@derickr
Copy link

derickr commented Aug 29, 2021

It's spelled "Xdebug" (no capital "D").

XDebug shouldn't be installed unless specified by the user.

FWIW, I don't think this is wise, as you're going to make it harder for people to get a working debugging setup.

@brylie
Copy link
Contributor Author

brylie commented Aug 30, 2021

It's spelled "Xdebug" (no capital "D").

Thanks for pointing that out. I corrected the title and description 😃

FWIW, I don't think this is wise, as you're going to make it harder for people to get a working debugging setup.

From what I understand config.xdebug defaults to off.

This pull request avoids automatically installing Xdebug when config.xdebug === 'off'. When the developer specifies an xdebug value other than off, Xdebug will be installed.

It may be worth pointing out that wp-env/Docker will re-build the development container when enabling Xdebug, so it may be OK to omit the Xdebug installation step in cases where it isn't needed.

@brylie brylie changed the title Disable XDebug by default unless specified by user Disable Xdebug by default unless specified by user Aug 30, 2021
@brylie
Copy link
Contributor Author

brylie commented Aug 30, 2021

There is currently no way to disable the Xdebug installation, even when it is desirable to do so. I am encountering a bug during the Xdebug installation (#34320) step and would just like to bypass the Xdebug installation to continue with my development task.

image

For simplicity's sake, it is important only to install dependencies that are needed.

@koengabriels
Copy link

hope this gets through because I am working for a client that uses wp-env to set up unit tests on their precommit hook
since I am getting this error and have been unable to bypass it... I can not commit anything :(

@brylie
Copy link
Contributor Author

brylie commented Sep 29, 2021

@koengabriels would you mind taking a close look at the code and possibly testing it on your end? Your peer review would be much appreciated 😃

@koengabriels
Copy link

@brylie I have to look into how to do that, I have zero experience with testing a PR from Github or wp-env code base
if I can I will post feedback here, appreciate the time you took to create a pull request for this issue 🙂

Copy link
Member

@noahtallen noahtallen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a couple comments, but I think we can move forward with this.

This doesn't change the public API for using xdebug with wp-env, so it isn't any harder to enable with wp-env. 👍

I tested locally, and it will create a wordpress image without xdebug by default, and one with xdebug as soon as the --xdebug flag is passed.

Another note is to run prettier locally to get the lint check passing 👍

packages/env/lib/init-config.js Outdated Show resolved Hide resolved
packages/env/lib/init-config.js Show resolved Hide resolved
packages/env/lib/init-config.js Outdated Show resolved Hide resolved
@noahtallen noahtallen added [Tool] Env /packages/env [Type] Enhancement A suggestion for improvement. labels Oct 27, 2021
@brylie brylie mentioned this pull request Oct 28, 2021
7 tasks
@brylie
Copy link
Contributor Author

brylie commented Oct 28, 2021

@noahtallen, I've incorporated your suggested changes to the nested logic and conditional as well as the suggestion from PR #35667

Are there any other changes you would recommend?

Copy link
Member

@noahtallen noahtallen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This tests well for me, thank you for implementing the suggestions!

I don't have access to merge unless the CI checks are passing. I'd recommend running prettier/eslint again and rebasing the PR on the latest trunk changes.

It would also be great if you could add a line to the changelog (https://github.com/WordPress/gutenberg/blob/trunk/packages/env/CHANGELOG.md) under the "unreleased" section (probably under a new heading ### Enhancement)

Other than that, I think this is good to go 👍

@brylie
Copy link
Contributor Author

brylie commented Oct 29, 2021

Sorry for the review request bonanza. I tried to rebase changes from trunk into this branch so the CI tasks would succeed.

Would someone with admin rights please help bypass the CI review since most tasks are unrelated to this pull request?

@noahtallen, would you please review the recent changes to this PR? I've refactored the PHP compatibility check into its own function so the dockerFileContents function is single-purpose.

@swissspidy
Copy link
Member

Why bypass CI review?

There are some actual lint errors in packages/env/lib/init-config.js that need to get addressed.

@brylie
Copy link
Contributor Author

brylie commented Oct 29, 2021

Another note is to run prettier locally to get the lint check passing

When I run npm run format-js locally, I get the following error:

$ npm run format-js

> [email protected] format-js
> wp-scripts format-js

sh: 1: wp-scripts: not found

When I have tried running npm install, I get many errors related to Tracker "idealTree:inflate:s" already exists

2021-10-29T08_01_35_754Z-debug.log.txt

I believe these issues are related to the monorepo nature of this project whereby it is necessary to install the entire Gutenberg development stack as well as any other libraries published by @wordpress in order to work on wp-env

#34325

@swissspidy
Copy link
Member

Yes it's a monorepo and you'd need to run npm install from the repo root.

You should also be using the latest Node LTS, Node 16 (run nvm install to fix). According to your logs you are still on Node 12

@brylie
Copy link
Contributor Author

brylie commented Oct 29, 2021

I ran nvm install 16 && nvm use 16:
image

Running npm install in the monorepo root seems to have produced pretty much the same errors:

2021-10-29T08_48_38_880Z-debug.log.txt

@brylie
Copy link
Contributor Author

brylie commented Oct 29, 2021

@noahtallen, it seems like the CI checks are all passing or skipped. Would you mind giving this another review?

@noahtallen
Copy link
Member

I ran nvm install 16 && nvm use 16:

For future reference, I think this is because gutenberg still requires npm v6. I think there is a project to update that, though.

But now that CI is passing, it shouldn't be a problem for this PR :)

Copy link
Member

@noahtallen noahtallen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The latest changes also test well, thank you!

This change will get released to npm whenever the gutenberg project does its next npm release, though I'm not sure when that will be unfortunately. I think the schedule changes around WordPress release windows

@noahtallen noahtallen merged commit 14a30f0 into WordPress:trunk Oct 29, 2021
@github-actions github-actions bot added this to the Gutenberg 11.9 milestone Oct 29, 2021
@brylie brylie deleted the patch-2 branch November 1, 2021 07:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Tool] Env /packages/env [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants