You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In various instances throughout the @wordpress/env documentation, the run commands are illustrated with double quotes, as demonstrated in the following example from here:
wp-env run cli "wp rewrite structure /%postname%/"
This format is also used in libraries such as @10up/cypress-wp-utils for wp Cli commands with wp-env. However, this approach ceased functioning since wp-env 7.0.0.
Upon investigation, I identified the issue in the /packages/env/lib/commands/run.js file, specifically within the showCommandTips function, which stems from modifications introduced in the following pull requests:
#50559 - Reworked run Command Parsing #50007 - Improve run command execution speed
Step-by-step reproduction instructions
Install wp-env in a new project with vevrsion 7.0.0 or newer
Start the env with npm run env:start
Run any command with double quotes, as npm run env run tests-cli "plugin list", then you should receive the following error:
$ npm run env run tests-cli "plugin list">[email protected] env
> wp-env run tests-cli plugin list
ℹ Starting 'plugin list' on the tests-cli container.
OCI runtime exec failed: exec failed: container_linux.go:380: starting container process caused: exec: "plugin list": executable file not found in$PATH: unknown
✖ Command failed with exit code 126
Command failed with exit code 126
Screenshots, screen recording, code snippet
After modifying the showCommandTips function in /packages/env/lib/commands/run.js to the following code snippet, the run command starts to work correctly. However, I do not see this as a fix at this time, as it negates the performance improvements introduced by utilizing exec instead of run in #50007.
/** * Runs an arbitrary command on the given Docker container. * * @param {WPConfig} config The wp-env configuration. * @param {string} container The Docker container to run the command on. * @param {string[]} command The command to run. * @param {string} envCwd The working directory for the command to be executed from. * @param {Object} spinner A CLI spinner which indicates progress. */functionspawnCommandDirectly(config,container,command,envCwd,spinner){// Both the `wordpress` and `tests-wordpress` containers have the host's// user so that they can maintain ownership parity with the host OS.// We should run any commands as that user so that they are able// to interact with the files mounted from the host.consthostUser=getHostUser();// Since Docker requires absolute paths, we should resolve the input to a POSIX path.// This is needed because Windows resolves relative paths from the C: drive.envCwd=path.posix.resolve(// Not all containers have the same starting working directory.container==='mysql'||container==='tests-mysql'
? '/'
: '/var/www/html',// Remove spaces and single quotes from both ends of the path.// This is needed because Windows treats single quotes as a literal character.envCwd.trim().replace(/^'|'$/g,''));constcomposeCommand=['compose','-f',config.dockerComposeConfigPath,'run','-w',envCwd,'--user',hostUser.fullUser,'--rm',];if(!process.stdout.isTTY){composeCommand.push('-T');}composeCommand.push(container, ...command);returnnewPromise((resolve,reject)=>{// Note: since the npm docker-compose package uses the -T option, we// cannot use it to spawn an interactive command. Thus, we run docker-// compose on the CLI directly.constchildProc=spawn('docker',composeCommand,{stdio: 'inherit',shell: true,},spinner);childProc.on('error',reject);childProc.on('exit',(code)=>{// Code 130 is set if the user tries to exit with ctrl-c before using// ctrl-d (so it is not an error which should fail the script.)if(code===0||code===130){resolve();}else{reject(`Command failed with exit code ${code}`);}});});}
Environment info
Node v16.20.2
Linux - Pop!_OS 22.04 LTS (also tested on a mac M1)
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
No
The text was updated successfully, but these errors were encountered:
Description
In various instances throughout the
@wordpress/env
documentation, therun
commands are illustrated with double quotes, as demonstrated in the following example from here:wp-env run cli "wp rewrite structure /%postname%/"
This format is also used in libraries such as
@10up/cypress-wp-utils
for wp Cli commands with wp-env. However, this approach ceased functioning since wp-env 7.0.0.Upon investigation, I identified the issue in the
/packages/env/lib/commands/run.js
file, specifically within theshowCommandTips
function, which stems from modifications introduced in the following pull requests:#50559 - Reworked
run
Command Parsing#50007 - Improve run command execution speed
Step-by-step reproduction instructions
npm run env:start
npm run env run tests-cli "plugin list"
, then you should receive the following error:Screenshots, screen recording, code snippet
After modifying the
showCommandTips
function in/packages/env/lib/commands/run.js
to the following code snippet, the run command starts to work correctly. However, I do not see this as a fix at this time, as it negates the performance improvements introduced by utilizingexec
instead ofrun
in #50007.Environment info
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
No
The text was updated successfully, but these errors were encountered: