diff --git a/package.json b/package.json index e506c964d7de7..a0b92003074e8 100644 --- a/package.json +++ b/package.json @@ -140,7 +140,7 @@ "lint:jsdoc": "wp-scripts lint-js", "lint:jsdoc:fix": "wp-scripts lint-js --fix", "typecheck:js": "tsc --build", - "env:start": "node ./tools/local-env/scripts/start.js && node ./tools/local-env/scripts/docker.js run -T --rm php composer update -W", + "env:start": "node ./tools/local-env/scripts/start.js", "env:stop": "node ./tools/local-env/scripts/docker.js down", "env:restart": "npm run env:stop && npm run env:start", "env:clean": "node ./tools/local-env/scripts/docker.js down -v --remove-orphans", diff --git a/tools/local-env/scripts/start.js b/tools/local-env/scripts/start.js index 984e06bee5617..d811ca11ecbe8 100644 --- a/tools/local-env/scripts/start.js +++ b/tools/local-env/scripts/start.js @@ -93,3 +93,14 @@ if ( process.env.DOCKER_TOOLBOX_INSTALL_PATH ) { { stdio: 'inherit' } ); } + +// `composer update` reaches repo.packagist.org, so it is re-attempted for the same reasons as `up`. +const composer = local_env_utils.compose_with_retry( [ 'run', '-T', '--rm', 'php', 'composer', 'update', '-W' ], 3 ); + +if ( composer.status !== 0 ) { + console.error( '\nThere was an error while running PHP Composer update.' ); + console.error( 'This is often caused by network issues or Packagist.org downtime.' ); + console.error( 'Please check your internet connection and try again.' ); + + process.exit( composer.status ?? 1 ); +}