0

I have been using @wordpress/env for a few weeks, starting it with npm run wp-env start. Since this morning, that now fails with:

> wp-env "start"

✖ error: Your local changes to the following files would be overwritten by checkout:
        wp-content/themes/twentytwentyone/assets/css/ie.css
        wp-content/themes/twentytwentyone/assets/sass/01-settings/file-header.scss
        wp-content/themes/twentytwentyone/style-rtl.css
        wp-content/themes/twentytwentyone/style.css
Please commit your changes or stash them before you switch branches.
Aborting

GitError: error: Your local changes to the following files would be overwritten by checkout:
        wp-content/themes/twentytwentyone/assets/css/ie.css
        wp-content/themes/twentytwentyone/assets/sass/01-settings/file-header.scss
        wp-content/themes/twentytwentyone/style-rtl.css
        wp-content/themes/twentytwentyone/style.css
Please commit your changes or stash them before you switch branches.
Aborting

    at Object.action (/home/alice/wp-demo-theme/node_modules/simple-git/dist/cjs/index.js:1228:25)
    at PluginStore.exec (/home/alice/wp-demo-theme/node_modules/simple-git/dist/cjs/index.js:1263:29)
    at /home/alice/wp-demo-theme/node_modules/simple-git/dist/cjs/index.js:1627:43
    at new Promise (<anonymous>)
    at GitExecutorChain.handleTaskData (/home/alice/wp-demo-theme/node_modules/simple-git/dist/cjs/index.js:1625:16)
    at GitExecutorChain.<anonymous> (/home/alice/wp-demo-theme/node_modules/simple-git/dist/cjs/index.js:1609:44)
    at Generator.next (<anonymous>)
    at fulfilled (/home/alice/wp-demo-theme/node_modules/simple-git/dist/cjs/index.js:55:24) {
  task: {
    commands: [ 'checkout', '6.1.1' ],
    format: 'utf-8',
    parser: [Function: parser]
  }
}

The error message talks about "your local changes", but I have not modified any files in the twentytwentyone theme folder. wp-env seems to have brought this on itself.

I have tried removing the Docker image for WordPress and starting again, but the problem persists. I have tried wp-env start --update - that does not fix it either. The Docker container does not stay up so I cannot get into it (with docker exec) to remove those changes.

Any idea how I can get wp-env working again?

4
  • Do the mentioned files have changes in them and are they meant to be in there?
    – kero
    Nov 17, 2022 at 16:36
  • 3
    looks like you've modified the twentytwentyone theme directly instead of creating a child theme to store your changes. Copying the folder was also an option. Fixing this means you need to undo those changes to fix the problem. Note that you shouldn't be using core WP develop for anything other than contributing to WordPress itself, it's not intended for client work/personal projects/etc
    – Tom J Nowell
    Nov 17, 2022 at 16:46
  • I have not modified any files in the folder described in the error message. This seems to be entirely down to @wordpress/env.
    – Duncan T
    Nov 18, 2022 at 9:13
  • A few weeks after I posted this, the problem mysteriously went away without me changing anything. Now it is back again. I haven't changed anything. The process of starting wp-env clearly pulls something onto my machine, so presumably that has changed. Has anyone else seen this kind of problem?
    – Duncan T
    Apr 4, 2023 at 9:28

1 Answer 1

1

I had the same problem with a completely new installation of wp-env.

In my case, the error apparently originated from wp-env downloading PHPUnit in node_modules/@wordpress/env/lib/download-wp-phpunit.js.

Commenting line 137 (version 5.14.0) in download-wp-phpunit.js resolved the problem:

log( `Fetching ${ ref }.` );
await git.raw( fetchRaw );

log( `Checking out ${ ref }.` );
// await git.checkout( ref ); <--- Comment this line

onProgress( 1 );

Please note that this is only a temporary solution, and the problem will surface again after an update of wp-env.

If you have wp-env installed globally and locally, be sure to use the right one after the change (or change both, if necessary).

This will likely impact the usage of PHPUnit. I'm just trying out wp-env, so I cannot comment on the scope of this change. Someone with more experience on the tool and a deeper understanding should probably dig deeper into this if more people are affected.

1
  • Thanks for sharing that, Michael
    – Duncan T
    Apr 4, 2023 at 9:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.