diff --git a/README.md b/README.md index 6c2a98ec93..3d0dc8b557 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,8 @@ WP-CLI version: 0.25.0 You can update WP-CLI with `wp cli update` ([doc](https://wp-cli.org/commands/cli/update/)), or by repeating the installation steps. +If WP-CLI is owned by root or another system user, you'll need to run `sudo wp cli update`. + Want to live life on the edge? Run `wp cli update --nightly` to use the latest nightly build of WP-CLI. The nightly build is more or less stable enough for you to use in your development environment, and always includes the latest and greatest WP-CLI features. ### Tab completions diff --git a/php/WP_CLI/Runner.php b/php/WP_CLI/Runner.php index 34d60cdff1..0700d01ee7 100644 --- a/php/WP_CLI/Runner.php +++ b/php/WP_CLI/Runner.php @@ -661,12 +661,18 @@ private function init_config() { } private function check_root() { - if ( $this->config['allow-root'] ) + if ( $this->config['allow-root'] ) { return; # they're aware of the risks! - if ( !function_exists( 'posix_geteuid') ) + } + if ( count( $this->arguments ) >= 2 && 'cli' === $this->arguments[0] && 'update' === $this->arguments[1] ) { + return; # make it easier to update root-owned copies + } + if ( !function_exists( 'posix_geteuid') ) { return; # posix functions not available - if ( posix_geteuid() !== 0 ) + } + if ( posix_geteuid() !== 0 ) { return; # not root + } WP_CLI::error( "YIKES! It looks like you're running this as root. You probably meant to " .