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

wp-env won't run Gutenberg without an Internet connection #53433

Closed
ockham opened this issue Aug 8, 2023 · 3 comments · Fixed by #53547
Closed

wp-env won't run Gutenberg without an Internet connection #53433

ockham opened this issue Aug 8, 2023 · 3 comments · Fixed by #53547
Labels
[Package] Env /packages/env [Type] Bug An existing feature does not function as intended

Comments

@ockham
Copy link
Contributor

ockham commented Aug 8, 2023

Description

I’ve noticed that as of late, @wordpress/env requires an internet connection to run a local copy of the Gutenberg repo; otherwise, npm run wp-env start will abort with an error message (see below).

This is unfortunate, as it prevents working on Gutenberg while offline (e.g. on a plane etc).


The problem is due to getLatestWordPressVersion, which includes a call to the https://api.wordpress.org/core/stable-check/1.0/ endpoint. Ideally, we find a fallback to make wp-env work even without an internet connection.

getLatestWordPressVersion was introduced in #43133. AFAICT, the rationale behind it was to default to the current WordPress version in case there was none specified in .wp-env.json.

This makes sense; however, it'd be great if we could avoid the side effect of wp-env not working altogether when offline.

My vague idea about getting this to work offline would be to check if the local ~/.wp-env cache directory contains any Docker images that match the config in .wp-env.json -- IIRC, we create some kind of hash based on the latter that we use to look up the corresponding ~/.wp-env subdirectory. Curious to hear your thoughts if that would be feasible @noahtallen


#52157 is probably due to the same underlying problem, but since it's specifically about wp-env install-path, I thought it'd make sense to file a separate issue. cc/ @swissspidy @t-hamano

Step-by-step reproduction instructions

  1. Disable your Internet connection.
  2. Run npm run wp-env start.
  3. You'll see the following error:
✖ getaddrinfo ENOTFOUND api.wordpress.org
RequestError: getaddrinfo ENOTFOUND [api.wordpress.org](http://api.wordpress.org/)

Screenshots, screen recording, code snippet

No response

Environment info

No response

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

@ockham ockham added [Type] Bug An existing feature does not function as intended [Package] Env /packages/env labels Aug 8, 2023
@noahtallen
Copy link
Member

Thanks for the report; definitely not a good side effect of that change 😅

One of the main reasons it exists is was to make sure WordPress updated to the latest version quickly when the underlying docker image doesn't. (Got a lot of reports about that too!)

Will try to find a fix 👍

@swissspidy
Copy link
Member

#52157 is probably due to the same underlying problem, but since it's specifically about wp-env install-path, I thought it'd make sense to file a separate issue.

I think it's mainly because I just ran into this issue when trying that specific command and my environment was already started, so I didn't bother checking other commands. Didn't wanna risk stopping the env and not being able to restart it without an internet connection :-)

So let's consolidate the two issues.

@noahtallen
Copy link
Member

I found a fix (#53547), which should make it work offline. Testing appreciated! There were two problems. One was the WordPress version check noted here, but after that was fixed, wp-env still attempt to pull docker images and sources, so I also fixed that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Env /packages/env [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants