close
Skip to content

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

@ockham

Description

@ockham

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

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions