@@ -51,11 +51,6 @@ public function __get( $key ) {
5151 */
5252 private function init_ee () {
5353
54- if ( ! is_dir ( EE_CONF_ROOT ) ) {
55- $ user = getenv ('USER ' );
56- shell_exec ('sudo mkdir -p ' . EE_CONF_ROOT );
57- }
58-
5954 $ this ->ensure_present_in_config ( 'sites_path ' , Utils \get_home_dir (). '/ee-sites ' );
6055 $ this ->ensure_present_in_config ( 'locale ' , 'en_US ' );
6156 $ this ->ensure_present_in_config ( 'ee_installer_version ' , 'stable ' );
@@ -485,7 +480,10 @@ public function init_logger() {
485480
486481 EE ::set_logger ( $ logger );
487482
488- $ this ->init_ee ();
483+ // Create the config directory if not exist for file logger to initialize.
484+ if ( ! is_dir ( EE_CONF_ROOT ) ) {
485+ shell_exec ('sudo mkdir -p ' . EE_CONF_ROOT );
486+ }
489487
490488 if ( ! is_writable ( EE_CONF_ROOT ) ) {
491489 EE ::err ( 'Please run `ee` as root user. ' );
@@ -626,11 +624,7 @@ private function ensure_present_in_config( $var, $default) {
626624 $ this ->add_var_to_config_file ( $ var , $ config_file_path );
627625 return ;
628626 }
629- $ mkdir_success = mkdir ( $ config_dir_path , 0755 , true );
630- if ( ! $ mkdir_success ) {
631- EE ::err ("The config file path $ {$ config_dir_path } is not writable. \n Please run `ee` it as root user. " );
632- }
633- $ this ->add_var_to_config_file ($ var , $ config_file_path );
627+ EE ::err ("Please run `ee` as root user. " );
634628 }
635629 }
636630 }
@@ -681,6 +675,8 @@ private function set_alias( $alias ) {
681675
682676 public function start () {
683677
678+ $ this ->init_ee ();
679+
684680 // Enable PHP error reporting to stderr if testing.
685681 if ( getenv ( 'BEHAT_RUN ' ) ) {
686682 $ this ->enable_error_reporting ();
0 commit comments