Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drush fails to detect sites other than default when a site-local drush is installed #2285

Closed
fago opened this issue Jul 21, 2016 · 42 comments
Closed

Comments

@fago
Copy link
Contributor

fago commented Jul 21, 2016

Similar as reported in #2070, detecting multi-site directories does not work when a site-local drush is in use. The reason is that a global drush 8 automatically picks the site-local drush up, but loses the directory context while doing so.

Steps to reproduce:

  • Install site-local drush via composer
  • Install global drush 8.*
  • Go into a working multi-site directory, like sites/my-site and run "drush st".

Expected:
A output of Drupal Settings File : sites/my-site/settings.php
Actual behaviour:
Drupal Settings File : sites/default/settings.php

@fago fago changed the title Drush launcher fails to detect sites other than default when a site-local drush is installed Drush preflight fails to detect sites other than default when a site-local drush is installed Jul 21, 2016
@fago fago changed the title Drush preflight fails to detect sites other than default when a site-local drush is installed Drush fails to detect sites other than default when a site-local drush is installed Jul 21, 2016
fago added a commit to fago/drush that referenced this issue Jul 21, 2016
@fago
Copy link
Contributor Author

fago commented Jul 21, 2016

Looks like there is simply a chdir() call causing that. It looks like thes chdir() is even unnecessary, in my tests removing it did not cause any troubles and fixed the problem.

See PR #2286

@weitzman
Copy link
Member

I'm working on a D8 multisite now, and I have not experienced this problem. I also call a global Drush which hands off to a site-local Drush. On D8 a sites.php is required in order for multisite to work. I mention that in case you are running D8.

Any chance you can zip up your site and send to me? Don't think I need the DB or uploaded files. If not, running with --debug might provide insights.

@fago
Copy link
Contributor Author

fago commented Jul 22, 2016

The problem appears on a Drupal 7 site. Unfortunately I cannot share the site, but it has sites.php configured as well. I can check whether this is redrocuable on a plain drupal 7, but I very much think so.

Here is the drush st --debug output in case it helps:

drush st --debug 
Using the Drush script found at /path/to/drupal/root/vendor/drush/drush/drush.launcher using pcntl_exec
Loading drushrc "/home/fago/.drush/drushrc.php" into "home.drush" scope. [0 sec, 3.79 MB]                                        [bootstrap]
Loading drushrc "/home/fago/.drush/drudrush/drushrc.php" into "custom" scope. [0.01 sec, 3.79 MB]                                [bootstrap]
Cache HIT cid: 8.0.5-commandfiles-0-26b8001111e3480fa6c27b7b14ecc42c [0.01 sec, 3.87 MB]                                             [debug]
Loading drushrc "/path/to/drupal/root/web/sites/all/drush/drushrc.php" into "drupal" scope. [0.03 sec, 7.96 MB]          [bootstrap]
Bootstrap to phase 0. [0.17 sec, 10.85 MB]                                                                                       [bootstrap]
Trying to bootstrap as far as we can. [0.17 sec, 10.86 MB]                                                                           [debug]
Drush bootstrap phase : bootstrap_drupal_root() [0.18 sec, 11.31 MB]                                                             [bootstrap]
Loading drushrc "/path/to/drupal/root/web/sites/all/drush/drushrc.php" into "drupal" scope. [0.18 sec, 11.31 MB]         [bootstrap]
Initialized Drupal 7.44 root directory at /path/to/drupal/root/web [0.18 sec, 11.31 MB]                                  [bootstrap]
Find command files for phase 1 (max=7) [0.18 sec, 8.48 MB]                                                                           [debug]
Cache HIT cid: 8.0.5-commandfiles-1-07aead10e03a07e47ed30ffa3962a7bf [0.19 sec, 8.49 MB]                                             [debug]
Drush bootstrap phase : bootstrap_drupal_site() [0.22 sec, 8.52 MB]                                                              [bootstrap]
Initialized Drupal site default at sites/default [0.22 sec, 8.52 MB]                                                             [bootstrap]
Find command files for phase 2 (max=7) [0.22 sec, 8.52 MB]                                                                           [debug]
Drush bootstrap phase : bootstrap_drupal_configuration() [0.22 sec, 8.52 MB]                                                     [bootstrap]
Find command files for phase 3 (max=7) [0.23 sec, 8.62 MB]                                                                           [debug]
sql-query: SELECT 1; [0.23 sec, 8.75 MB]                                                                                            [notice]
Executing: mysql --defaults-extra-file=/tmp/drush_knT2V6 --database=.. --host=...local --silent  < /tmp/drush_HmcG93
  1
sql-query: SHOW TABLES; [0.23 sec, 8.76 MB]                                                                                         [notice]
Executing: mysql --defaults-extra-file=/tmp/drush_6B8bxc --database=.. --host=...local --silent  < /tmp/drush_a9CBJ9
  actions
  authmap
  batch
  block
  block_custom
  block_node_type
  block_role
  blocked_ips
  cache
  cache_admin_menu
  cache_block
  cache_bootstrap
  cache_entity_comment
  cache_entity_file
 ....
Drush bootstrap phase : bootstrap_drupal_database() [0.28 sec, 8.88 MB]                                                          [bootstrap]
Successfully connected to the Drupal database. [0.28 sec, 9.49 MB]                                                               [bootstrap]
Find command files for phase 4 (max=7) [0.28 sec, 9.49 MB]                                                                           [debug]
Drush bootstrap phase : bootstrap_drupal_full() [0.28 sec, 9.49 MB]                                                              [bootstrap]
Cache HIT cid: 8.0.5-install_profile-66ecfeb9791a023150773849f1550c5d [0.66 sec, 58.74 MB]                                           [debug]
Find command files for phase 5 (max=7) [0.66 sec, 58.74 MB]                                                                          [debug]
Cache HIT cid: 8.0.5-install_profile-66ecfeb9791a023150773849f1550c5d [0.66 sec, 58.74 MB]                                           [debug]
Cache HIT cid: 8.0.5-commandfiles-5-ec91674843f7c2ecd5049a194fa8c46b [0.67 sec, 58.8 MB]                                             [debug]
Drush bootstrap phase : bootstrap_drupal_login() [0.67 sec, 59.92 MB]                                                            [bootstrap]
Find command files for phase 6 (max=7) [0.67 sec, 59.94 MB]                                                                          [debug]
Found command: core-status (commandfile=core) [0.67 sec, 59.94 MB]                                                               [bootstrap]
Loading outputformat engine. [0.81 sec, 63.61 MB]                                                                                   [notice]
Calling hook drush_core_status [0.81 sec, 63.74 MB]                                                                                  [debug]
Returned from hook drush_core_status [0.84 sec, 63.82 MB]                                                                            [debug]
 Drupal version                :  7.44                                                                                                
 Site URI                      :  http://default                                                                                      
 Database driver               :  mysql                                                                                               
 Database hostname             :  project.local                                                                                          
 Database port                 :                                                                                                      
 Database username             :  root                                                                                                
 Database name                 :  project

 Drupal bootstrap              :  Successful                                                                                          
 Drupal user                   :                                                                                                      
 Default theme                 :  project                                                                                       
 Administration theme          :  project_admin                                                                                 
 PHP executable                :  /usr/bin/php                                                                                        
 PHP configuration             :  /etc/php5/cli/php.ini                                                                               
 PHP OS                        :  Linux                                                                                               
 Drush script                  :  /path/to/drupal/root/vendor/drush/drush/drush.php                                           
 Drush version                 :  8.0.5                                                                                               
 Drush temp directory          :  /tmp                                                                                                
 Drush configuration           :  /home/fago/.drush/drudrush/drushrc.php /path/to/drupal/root/web/sites/all/drush/drushrc.php 
                                  /home/fago/.drush/drushrc.php                                                                       
 Drush alias files             :  /home/fago/.drush/clients.aliases.drushrc.php           
                                  /path/to/drupal/root/web/sites/all/drush/aliases.drushrc.php                                
 Install profile               :  standard                                                                                            
 Drupal root                   :  /path/to/drupal/root/web                                                                    
 Drupal Settings File          :  sites/default/settings.php                                                                          
 Site path                     :  sites/default                                                                                       
 File directory path           :  files                                                                                               
 Private file directory path   :  sites/default/private                                                                               
 Temporary file directory      :  /tmp                                                                                                
 path                                                                                                                                 

Command dispatch complete [0.85 sec, 63.96 MB]                                                                                      [notice]
 Timer  Cum (sec)  Count  Avg (msec) 
 page   0.63       1      629.82

@weitzman
Copy link
Member

I used the following commands (adjust for your DB server as needed) but could not reproduce the problem. It would be great if you tried with latest Drush (8.x or master, both global and site-local).

composer create-project drupal-composer/drupal-project:7.x-dev d7composer --stability dev --no-interaction
cd d7composer
composer require drush/drush dev-8.x
composer install
cd web
drush si --db-url=mysql://root:@127.0.0.1:33067/d7composer -v
drush si --db-url=mysql://root:@127.0.0.1:33067/d7c2 -v  --sites-subdir=d7c2
cd sites/d7c2
drush status

My output has Site path : sites/d7c2 as expected.

@fago
Copy link
Contributor Author

fago commented Oct 12, 2016

Coming back to this one after running into the applied patch. Sry for not responding earlier, I missed your update.

I tested the problem with your commands, just slightly adapted to use my fitting db-credentials and drush in version "8.x-dev". When I ran drush status from sites/d7c2 I get:

 drush status | grep "Site path"
 Site path                       :  sites/default

Thus, I can reproduce the problem with above steps. I've no idea why this problem is not there for you though. I made sure I've got drush 8.x-dev 72494ac installed both globally and at project level still same results.

Then, after applying the changes from PR-#2286 it works as it should:

cd ~/.composer/vendor/drush/drush/
curl https://patch-diff.githubusercontent.com/raw/drush-ops/drush/pull/2286.patch | patch -p1 
cd path/to/web/sites/d7c2
drush status | grep "Site path"
 Site path                       :  sites/d7c2

@fago
Copy link
Contributor Author

fago commented Oct 12, 2016

Can we re-open this? Looks like I cannot.

@weitzman weitzman reopened this Oct 12, 2016
@fago
Copy link
Contributor Author

fago commented Oct 19, 2016

Thanks moshe! What's needed to move on with this issue? PR #2286 still works and resolves the issue for me.

@weitzman
Copy link
Member

Can you reproduce the problem with the steps I posted? If not, what steps are needed? I need to see the bug to know if thats a good fix.

@fago
Copy link
Contributor Author

fago commented Oct 19, 2016

Yes, as written above I was able to reproduce with the steps that you provided:

I tested the problem with your commands, just slightly adapted to use my fitting db-credentials and drush in version "8.x-dev".

-> The only thing that I had to change was the drush version - I used "8.x-dev" what shoud be fine.
I tested it on Ubuntu 16.04 with its default PHP environment, which is PHP 7.

@miromichalicka
Copy link

I can reproduce error as well. Tested on multiple environments (OS X + PHP7, Debian8 + PHP5.6, Ubuntu 16.04 + PHP5.6). Workaround is to use -l option which is quite inconvenient.
Patch from #2286 is not working for me unfortunately.

@PatrickBauer
Copy link
Contributor

PatrickBauer commented Nov 10, 2016

I can report the same issue. We're using a multi-site environment without a default site and any drush command (with our without --uri='' and in root or in a sites folder), returns:

The specified database connection is not defined: default

Because the default site doesn't have any configuration.

Edit:
Patch #2286 works, BUT only on our MacOS machines, not on our linux machines. May that help find the bug @weitzman ?

@dakkusingh
Copy link

dakkusingh commented Apr 10, 2017

I also have the same issue..

cd into the site folder

[dakku@server mysite.com]$ pwd
/var/www/html/d8/web/sites/mysite.com

Checking drush path

[dakku@server mysite.com]$ which drush
~/.composer/vendor/bin/drush

Drush st in my site folder

[dakku@server mysite.com]$ drush st
 Drupal version         :  8.3.0                                         
 Site URI               :  http://default                                
 PHP executable         :  /usr/bin/php                                  
 PHP configuration      :  /etc/php.ini                                  
 PHP OS                 :  Linux                                         
 Drush script           :  /var/www/html/d8/vendor/drush/drush/drush.php 
 Drush version          :  8.1.10                                        
 Drush temp directory   :  /tmp                                          
 Drush configuration    :                                                
 Drush alias files      :                                                
 Drupal root            :  /var/www/html/d8/web                          
 Drupal Settings File   :  sites/default/settings.php                    
 Site path              :  sites/default                                 
 Sync config path       :  ../config/sync                                

Running Drush with -l option

[dakku@server mysite.com]$ drush -l mysite.com st
 Drupal version                  :  8.3.0                                                                                                             
 Site URI                        :  mysite.com                                                                                                    
 Database driver                 :  mysql                                                                                                             
 Database hostname               :  localhost                                                                                                         
 Database port                   :  3306                                                                                                              
 Database username               :  drupal                                                                                                            
 Database name                   :  drupal8_mysite_com                                                                                            
 Database                        :  Connected                                                                                                         
 Drupal bootstrap                :  Successful                                                                                                        
 Drupal user                     :                                                                                                                    
 Default theme                   :  bootstrap                                                                                                         
 Administration theme            :  seven                                                                                                             
 PHP executable                  :  /usr/bin/php                                                                                                      
 PHP configuration               :  /etc/php.ini                                                                                                      
 PHP OS                          :  Linux                                                                                                             
 Drush script                    :  /var/www/html/d8/vendor/drush/drush/drush.php                                                                     
 Drush version                   :  8.1.10                                                                                                            
 Drush temp directory            :  /tmp                                                                                                              
 Drush configuration             :                                                                                                                    
 Drush alias files               :                                                                                                                    
 Install profile                 :  minimal                                                                                                           
 Drupal root                     :  /var/www/html/d8/web                                                                                              
 Drupal Settings File            :  sites/mysite.com/settings.php                                                                                 
 Site path                       :  sites/mysite.com                                                                                              
 File directory path             :  sites/mysite.com/files                                                                                        
 Temporary file directory path   :  /tmp                                                                                                              
 Sync config path                :  sites/mysite.com/files/config_foobar/sync 

@carlosmirandalevy
Copy link

I keep having the same problem on Drupal 8 installed with composer, which includes drush.
My Drupal installed without composer works fine.
And an Open Social distribution installed via composer also works fine.

I removed the drush 8.1.12 installed by composer, doing composer remove drush/drush and my non-composer installed drush 8.1.3 works fine from any multisite directory.

This on Ubuntu 16.04 multisite standard installation on all 3 cases.

@BR0kEN-
Copy link

BR0kEN- commented Jul 31, 2017

A new PR which also solves the problem but keeping a possibility to seek the launcher in different directories (#2860). - Unfortunately, it does not solve the problem in 100% cases.

@oraculi
Copy link

oraculi commented Jan 19, 2018

I believe I'm encountering the same situation(s) described above.

  1. Drupal 8 installed via Composer
    composer create-project drupal-composer/drupal-project:8.x-dev d8-4-test --stability dev --no-interaction
  2. Configure Drupal multisite with no actual site configured in /sites/default
  3. Drush st shows Site URI as http://default
  4. Drush -l sitename.org st displays the expected Site URI

This is on a Debian "Jessie" server with php 5.6. The same version of Drush ( 8.1.15) is installed globally and locally as part of the Drupal install.

Removing the local version of drush via composer remove drush/drush and relying on the global version of Drush restores everything to the expected functionality and is my current workaround.

Happy to help with testing or provide more info about my setup.

@weitzman
Copy link
Member

Are you located in the sites subdirectory when you make the cli request?

Are you using any symlinks?

@oraculi
Copy link

oraculi commented Jan 22, 2018

I'm in /composer-root/web/sites/sitename.org/ when running drush st

I don't have any symlinks in the Drupal directory structure. My global install of drush does rely on a symlink: /usr/local/bin/drush is a symlink to /home/myusername/.composer/vendor/bin/drush

@rthideaway
Copy link

Actually, today I also run into this issue. My global drush version is 8.1.15 and I currently have multisite Drupal instance with two sites. When trying to run drush st from within the second site, it is incorrectly displaying status of default site.

However, by applying patch from this #2286 the issue got fixed.

@darrenoh
Copy link
Contributor

With Drush 9.2.1, neither an alias nor the --uri option can make Drush use a directory other than sites/default as the site path.

@Pederytter
Copy link

Yeah I had the same issue as @darrenoh, not sure if there is a fix currently.

My solution was going back to drush 8

@markdorison
Copy link

With Drush 9.2.1, neither an alias nor the --uri option can make Drush use a directory other than sites/default as the site path.

I am experiencing the same issue.

@gregharvey
Copy link

Same here - multisite deployments are broken by drush 9, as we've always assumed if you're in the correct sites directory then drush will use the correct site settings to do things like clear cache and update the db - it's definitely not doing that. Here's the CLI output from a drush 9 test I ran just now:

jenkins@dev4:/var/www/live.example-drupal.8.x-multisite/www$ cd sites/siteb/
jenkins@dev4:/var/www/live.example-drupal.8.x-multisite/www/sites/siteb$ drush -y cr --debug
Using the Drush script found at /var/www/example-drupal_8.x-multisite_build_9/www/vendor/drush/drush/drush using pcntl_exec
 [preflight] Config paths: /var/www/example-drupal_8.x-multisite_build_9/www/vendor/drush/drush/drush.yml
 [preflight] Alias paths: /var/www/example-drupal_8.x-multisite_build_9/www/drush/sites,/var/www/example-drupal_8.x-multisite_build_9/www/drush/sites
 [preflight] Commandfile search paths: /var/www/example-drupal_8.x-multisite_build_9/www/vendor/drush/drush/src
 [bootstrap] Bootstrap to site [0.24 sec, 12.64 MB]
 [bootstrap] Drush bootstrap phase 2 [0.24 sec, 12.65 MB]
 [bootstrap] Try to validate bootstrap phase 2 [0.24 sec, 12.65 MB]
 [bootstrap] Try to validate bootstrap phase 2 [0.24 sec, 12.65 MB]
 [bootstrap] Try to bootstrap at phase 2 [0.24 sec, 12.88 MB]
 [bootstrap] Drush bootstrap phase: bootstrapDrupalRoot() [0.24 sec, 12.88 MB]
 [bootstrap] Change working directory to /var/www/example-drupal_8.x-multisite_build_9/www [0.24 sec, 12.88 MB]
 [bootstrap] Initialized Drupal 8.3.3 root directory at /var/www/example-drupal_8.x-multisite_build_9/www [0.24 sec, 12.88 MB]
 [bootstrap] Try to validate bootstrap phase 2 [0.24 sec, 12.88 MB]
 [bootstrap] Try to bootstrap at phase 2 [0.25 sec, 13.86 MB]
 [bootstrap] Drush bootstrap phase: bootstrapDrupalSite() [0.25 sec, 13.86 MB]
 [bootstrap] Initialized Drupal site default at sites/default [0.25 sec, 13.86 MB]
 [success] Cache rebuild complete. [3.05 sec, 49.87 MB]

Note specifically Initialized Drupal site default at sites/default <- that's a whole lot of 'nope' right there! Without the -l option at the moment drush 9 is basically not usable for multisites.

Be good to know if the drush team consider this a bug and are fixing, or I should start the refactor of code so it expects to use -l rather than assuming if you've cded to the correct directory it will be fine?

Thanks,

Greg

@gregharvey
Copy link

gregharvey commented May 7, 2018

Wow, OK, so I downgraded to drush 8.x but I have the same problem (we don't do much multisite, so hadn't spotted this before). Check out the CLI output:

jenkins@dev4:/var/www/live.example-drupal.8.x-multisite/www$ cd sites/sitec/
jenkins@dev4:/var/www/live.example-drupal.8.x-multisite/www/sites/sitec$ drush --version
 Drush Version   :  8.1.16 

jenkins@dev4:/var/www/live.example-drupal.8.x-multisite/www/sites/sitec$ drush status --format=yaml 2>&1 | grep "uri: " 
uri: 'http://default'
jenkins@dev4:/var/www/live.example-drupal.8.x-multisite/www/sites/sitec$ drush status -l sitec --format=yaml 2>&1 | grep "uri: " 
uri: sitec

So drush 8.1 seems pretty broken too. I couldn't go back to drush 8.0 to try, too many broken dependencies. I know drush 7.4 is fine, because we have a couple of Drupal 7 multisite clients using it without problems.

I might have to bite the bullet and implement the -l option, as our scripts are basically broken for Drupal 8 multisite without it. Sad face.

@weitzman
Copy link
Member

weitzman commented May 7, 2018 via email

weitzman added a commit that referenced this issue May 7, 2018
…ootstrapping a site. Affects hosts that have pcntl_exec().
@weitzman
Copy link
Member

weitzman commented May 7, 2018

I posted a fix for Drush 8 to #3550. Please test that and let me know how it there how it goes. Sorry it took so long. I didn't think of just doing another chdir() when I last looked at this.

I still can't reproduce this on Drush9. If folks could post STR that would be helpful. Start with composer create-project drupal-composer/drupal-project:8.x-dev some-dir --stability dev --no-interaction

@gregharvey
Copy link

For drush 8 I patched vendor/drush/drush/includes/startup.inc with #3550 (is that correct?) but I'm still seeing the same behaviour.

@weitzman
Copy link
Member

weitzman commented May 7, 2018

Thanks. Whats the value passed to the new chdir(). Can you echo that? At same time would be helpful if you posted a new debug log.

@gregharvey
Copy link

Of course, sorry! Just letting a test build finish then I'll re-patch and post something more meaningful for you!

@gregharvey
Copy link

So I'm definitely getting some weirdness. To complete the picture, we're using this Puppet module to install system-wide drush - https://forge.puppet.com/jonhattan/drush

It's always been fine in the past, but your earlier comments suggest this is no longer a good way to do things, and indeed it might be the cause of some issues here. Anyway, on to what I'm seeing.

At first this wasn't making much sense to me - I tried to write something to the terminal around where the patch is. At first I tried to simply fwrite() the variable but nothing came out, so I decided to put a debug line on either side of that if. I knew that code is running, because I see this in the output, which is just above in the code:

Using the Drush script found at /var/www/example-drupal_8.x-multisite_build_19/www/vendor/drush/drush/drush.launcher using pcntl_exec

But my fwrite() attempts were simply not appearing. Even though in the debug output I saw the above, which is pointing to the correct location. Banged my head against that for a while, then specified the full path to drush like so:

$ /var/www/example-drupal_8.x-multisite_build_19/www/vendor/drush/drush/drush  --version --debug
Using the Drush script found at /var/www/example-drupal_8.x-multisite_build_19/www/vendor/drush/drush/drush.launcher using pcntl_exec
>>>>>>>>>>>>> ARE USING PCNTL EXEC
>>>>>>>> /var/www/example-drupal_8.x-multisite_build_19/www/sites/sitec

Bingo! There's the output I wanted. And when I use the full path to drush I get the correct multisite behaviour, so your patch does indeed work.

If I don't specify a path, then I guess it's using system drush:

$ which drush
/usr/local/bin/drush

Which is fine. But what I don't get is why even when I use system drush, the debug output looks like this, making me think I'm not using system drush?

jenkins@dev4:/var/www/live.example-drupal.8.x-multisite/www/sites/sitec$ drush status --debug
Using the Drush script found at /var/www/example-drupal_8.x-multisite_build_19/www/vendor/drush/drush/drush.launcher using pcntl_exec
Cache HIT cid: 8.1.16-commandfiles-0-938b97084544dd69b52e5f6758551e43 [0.01 sec, 4.34 MB]                                                                                                                   [debug]
Bootstrap to phase 0. [0.19 sec, 11.31 MB]                                                                                                                                                              [bootstrap]
Trying to bootstrap as far as we can. [0.19 sec, 11.31 MB]                                                                                                                                                  [debug]
Drush bootstrap phase : bootstrap_drupal_root() [0.2 sec, 11.54 MB]                                                                                                                                     [bootstrap]
Initialized Drupal 8.3.3 root directory at /var/www/example-drupal_8.x-multisite_build_19/www [0.2 sec, 11.54 MB]                                                                                       [bootstrap]
Find command files for phase 1 (max=7) [0.21 sec, 9.15 MB]                                                                                                                                                  [debug]
Cache HIT cid: 8.1.16-commandfiles-1-d74c6ae8fdf66761dbfd78921ded6291 [0.21 sec, 9.15 MB]                                                                                                                   [debug]
Cache HIT cid: 8.1.16-annotationfiles-1-78ab2c637ec52d0bec1be5b1fe3bf2b4 [0.21 sec, 9.26 MB]                                                                                                                [debug]
Drush bootstrap phase : bootstrap_drupal_site() [0.23 sec, 10.25 MB]                                                                                                                                    [bootstrap]
Initialized Drupal site default at sites/default [0.23 sec, 10.25 MB]                                                                                                                                   [bootstrap]
Find command files for phase 2 (max=7) [0.23 sec, 10.25 MB]                                                                                                                                                 [debug]
Drush bootstrap phase : bootstrap_drupal_configuration() [0.24 sec, 10.25 MB]                                                                                                                           [bootstrap]
Create from request [0.24 sec, 10.3 MB]                                                                                                                                                                     [debug]
add service modifier [0.24 sec, 10.54 MB]                                                                                                                                                                   [debug]
Find command files for phase 3 (max=7) [0.24 sec, 10.54 MB]                                                                                                                                                 [debug]
sql-query: SELECT 1; [0.24 sec, 10.68 MB]                                                                                                                                                                  [notice]
Executing: mysql --defaults-extra-file=/tmp/drush_4p9Q3o --database=example-drup_1 --host=localhost --silent  < /tmp/drush_umzlgw
  1
sql-query: SHOW TABLES; [0.25 sec, 10.69 MB]                                                                                                                                                               [notice]
Executing: mysql --defaults-extra-file=/tmp/drush_kCLgHa --database=example-drup_1 --host=localhost --silent  < /tmp/drush_VakySh
  cache_bootstrap
  cache_config
  cache_container
  cache_data
  cache_default
  cache_discovery
  cache_dynamic_page_cache
  cache_entity
  cache_menu
  cache_render
  cachetags
  config
  file_managed
  file_usage
  key_value
  key_value_expire
  menu_tree
  node
  node__body
  node_access
  node_field_data
  node_field_revision
  node_revision
  node_revision__body
  queue
  router
  semaphore
  sequences
  sessions
  url_alias
  user__roles
  users
  users_data
  users_field_data
  watchdog
Drush bootstrap phase : bootstrap_drupal_database() [0.26 sec, 10.69 MB]                                                                                                                                [bootstrap]
Successfully connected to the Drupal database. [0.26 sec, 10.69 MB]                                                                                                                                     [bootstrap]
Find command files for phase 4 (max=7) [0.26 sec, 10.69 MB]                                                                                                                                                 [debug]
Drush bootstrap phase : bootstrap_drupal_full() [0.26 sec, 10.69 MB]                                                                                                                                    [bootstrap]
About to bootstrap the Drupal 8 Kernel. [0.26 sec, 10.7 MB]                                                                                                                                                 [debug]
Finished bootstraping the Drupal 8 Kernel. [0.3 sec, 16.12 MB]                                                                                                                                              [debug]
Cache MISS cid: 8.1.16-install_profile-66ecfeb9791a023150773849f1550c5d [0.3 sec, 16.28 MB]                                                                                                                 [debug]
Cache SET cid: 8.1.16-install_profile-66ecfeb9791a023150773849f1550c5d [0.31 sec, 16.29 MB]                                                                                                                 [debug]
Find command files for phase 5 (max=7) [0.31 sec, 16.29 MB]                                                                                                                                                 [debug]
Cache HIT cid: 8.1.16-install_profile-66ecfeb9791a023150773849f1550c5d [0.31 sec, 16.3 MB]                                                                                                                  [debug]
Cache HIT cid: 8.1.16-commandfiles-5-9b5582f4c7b1538f6db6c8f8614eaba6 [0.32 sec, 17.63 MB]                                                                                                                  [debug]
Drush bootstrap phase : bootstrap_drupal_login() [0.32 sec, 17.63 MB]                                                                                                                                   [bootstrap]
Find command files for phase 6 (max=7) [0.34 sec, 20.97 MB]                                                                                                                                                 [debug]
Found command: core-status (commandfile=core) [0.34 sec, 20.97 MB]                                                                                                                                      [bootstrap]
Loading outputformat engine. [0.51 sec, 23.61 MB]                                                                                                                                                          [notice]
Calling hook drush_core_status [0.52 sec, 23.94 MB]                                                                                                                                                         [debug]
Returned from hook drush_core_status [0.55 sec, 25.91 MB]                                                                                                                                                   [debug]
 Drupal version                  :  8.3.3                                                                                                                                                                   
 Site URI                        :  http://default                                                                                                                                                          
 Database driver                 :  mysql                                                                                                                                                                   
 Database hostname               :  localhost                                                                                                                                                               
 Database port                   :                                                                                                                                                                          
 Database username               :  example-drup_1                                                                                                                                                          
 Database name                   :  example-drup_1                                                                                                                                                          
 Database                        :  Connected                                                                                                                                                               
 Drupal bootstrap                :  Successful                                                                                                                                                              
 Drupal user                     :                                                                                                                                                                          
 Default theme                   :  stark                                                                                                                                                                   
 Administration theme            :  seven                                                                                                                                                                   
 PHP executable                  :  /usr/bin/php                                                                                                                                                            
 PHP configuration               :  /etc/php5/cli/php.ini                                                                                                                                                   
 PHP OS                          :  Linux                                                                                                                                                                   
 Drush script                    :  /var/www/example-drupal_8.x-multisite_build_19/www/vendor/drush/drush/drush.php                                                                                         
 Drush version                   :  8.1.16                                                                                                                                                                  
 Drush temp directory            :  /tmp                                                                                                                                                                    
 Drush configuration             :                                                                                                                                                                          
 Drush alias files               :  /etc/drush/examples_d7_example3_master.alias.drushrc.php /etc/drush/ctbto_master.alias.drushrc.php /etc/drush/bookworks_master.alias.drushrc.php                        
                                    /etc/drush/examples_d7_anothersite_master.alias.drushrc.php /etc/drush/stjohns_master.alias.drushrc.php /etc/drush/example-drupal_siteb_8.x-multisite.alias.drushrc.php 
                                    /etc/drush/example-drupal_8.x.alias.drushrc.php /etc/drush/example-drupal_sitec_8.x-multisite.alias.drushrc.php /etc/drush/examples_d7_master.alias.drushrc.php         
                                    /etc/drush/example-drupal_7.x.alias.drushrc.php /etc/drush/example-drupal_7.x-initial.alias.drushrc.php /etc/drush/who-hslp_training_toolkit_master.alias.drushrc.php   
                                    /etc/drush/example-drupal_sitea_8.x-multisite.alias.drushrc.php /etc/drush/veepeeone_master.alias.drushrc.php /etc/drush/my-sandbox_master.alias.drushrc.php            
                                    /etc/drush/codeenigma_new_master.alias.drushrc.php /etc/drush/busk_master.alias.drushrc.php /etc/drush/example-drupal_8.x-multisite.alias.drushrc.php                   
                                    /etc/drush/my-sandbox_templatetest.alias.drushrc.php                                                                                                                    
 Install profile                 :  minimal                                                                                                                                                                 
 Drupal root                     :  /var/www/example-drupal_8.x-multisite_build_19/www                                                                                                                      
 Drupal Settings File            :  sites/default/settings.php                                                                                                                                              
 Site path                       :  sites/default                                                                                                                                                           
 File directory path             :  sites/default/files                                                                                                                                                     
 Temporary file directory path   :  /tmp                                                                                                                                                                    
 Sync config path                :  ../config/sync                                                                                                                                                          

Command dispatch complete [0.59 sec, 26.07 MB]                                                                                                                                                             [notice]

That output looks to me like it claims to be using the drush in the project, but it isn't actually. So for all I know when I thought I was using drush 9, it may have been the system drush 8 reporting as drush 9 when I did a --version?

Weirdness!

weitzman added a commit that referenced this issue May 7, 2018
…ootstrapping a site. Affects hosts that have pcntl_exec(). (#3550)
@weitzman
Copy link
Member

weitzman commented May 7, 2018

When you use a global Drush like /usr/local/bin/drush, one of the first things it does is look for a project-specific Drush and if found, hand control to it. So thats why you are seeing reporting that looks like a site local Drush. The global Drush has already handed control.

I wonder if others who are reporting problems with Drush9 are similarly confused. If they are using Drush8 as a global launcher, the problem would be drush8 (and now fixed). ping @darrenoh, @markdorison, @Pederytter to learn if you are using a global launcher.

I suspect if you patch your global Drush, you won't need to patch project-specific one or pass in an absolute path. So, you have a few options on how to proceed.

I've just merged #3550. We can reopen this issue if there is indeed a Drush9 problem too.

@weitzman weitzman closed this as completed May 7, 2018
@darrenoh
Copy link
Contributor

darrenoh commented May 7, 2018

I’m using Drush Launcher, not Drush 8. And using the -l argument doesn’t help. Here is the output of drush -l https://home.darren.oh.name/drupal/8 status:

Drupal version   : 8.6.0-dev                                             
 Site URI         : https://home.darren.oh.name/drupal/8                  
 DB driver        : pgsql                                                 
 DB hostname      : localhost                                             
 DB port          : 5432                                                  
 DB username      : drupal                                                
 DB name          : drupal_8                                              
 Database         : Connected                                             
 Drupal bootstrap : Successful                                            
 Default theme    : bartik                                                
 Admin theme      : seven                                                 
 PHP binary       : /usr/bin/php                                          
 PHP config       : /etc/php.ini                                          
 PHP OS           : Darwin                                                
 Drush script     : /Library/Server/Web/Data/Sites/drupal/8/vendor/drush/ 
                    drush/drush                                           
 Drush version    : 9.2.1                                                 
 Drush temp       : /tmp                                                  
 Drush configs    : /Users/darren/.drush/drush.yml                        
                    /Library/Server/Web/Data/Sites/drupal/8/vendor/drush/ 
                    drush/drush.yml                                       
 Install profile  : standard                                              
 Drupal root      : /Library/Server/Web/Data/Sites/drupal/8               
 Site path        : sites/default                                         
 Files, Public    : sites/default/files                                   
 Files, Temp      : /tmp

The actual site path is sites/home.darren.oh.name.drupal.8.

@weitzman
Copy link
Member

weitzman commented May 7, 2018

Thanks @darrenoh. I assume you have created a sites.php? Thats a pre-requisite for multisite in D8. What is the contents of that file?

@gregharvey
Copy link

When you use a global Drush like /usr/local/bin/drush, one of the first things it does is look for a project-specific Drush and if found, hand control to it.

Right, but the problem is it categorically didn't do that. It claimed it handed control to the site-local drush, but I can repeatedly demonstrate it's not doing that with something as silly as an exit(); at the top of startup.inc.

What caused me so much confusion, and what I was trying to explain above, but there's probably too much in one post, is 'system' drush claimed to be launching 'local' drush, but it wasn't doing.

@weitzman
Copy link
Member

weitzman commented May 7, 2018 via email

@gregharvey
Copy link

Hmm, OK - point remains though, sometimes it's handing off, sometimes it isn't, and I have no idea why. Probably another issue entirely though.

@darrenoh
Copy link
Contributor

darrenoh commented May 7, 2018

@weitzman, the sites.php file is a copy of example.sites.php. Multisite is working without trouble in Drupal.

@weitzman
Copy link
Member

weitzman commented May 7, 2018

@darrenoh - when you say "a copy of example.sites.php", I assume you mean it also has $sites['home.darren.oh.name.drupal.8'] = 'home.darren.oh.name.drupal.8'; in it. Otherwise I don't see how your multi-site could be working.

When that line is present, then I am seeing your bug fixed when I use #3166. I'll work on fixing its test fails tomorrow. Lets move discussion there.

@darrenoh
Copy link
Contributor

darrenoh commented May 8, 2018

Drupal 8 checks site directories as long as sites.php is present. sites.php is not required to have content unless you want to use an alias for the site directory name.

@gaelg
Copy link
Contributor

gaelg commented Sep 26, 2018

I had the same problem because of an uppercase character in the subdir : sites/mySite. Changing to lowercase fixed it.

@Mark-Kiss
Copy link

sites.php indeed can be empty but must be there.
Here is the following issue about detection:
If I write drush status in drupal directory the global detects the local.
However if I write drush @myalias status it already handled by the global drush.
Please someone explain this to me, why aliasing has such an impact on detection.

@greg-1-anderson
Copy link
Member

@Mark-Kiss drush @myalias status should be equivalent to drush --root=/path --uri=subsite status for canonical aliases. If there is a site-local Drush, then Drush should always use it, regardless of how the site is specified. Are you getting different results than that?

@Mark-Kiss
Copy link

Yes! However there might be a reason for that. Let me first show you the phenomenon.
In both cases we are in the project root (which contains the Drupal root in web, it does not make a difference tho).

drush status

 Drush script     : /var/www/my_project/vendor/drush/drush/drush
 Drush version    : 9.5.2
 Drush configs    : /var/www/my_project/vendor/drush/drush/drush.yml
                    /var/www/my_project/drush/drush.yml
 Drupal root      : /var/www/my_project/web



drush @default status (could be any other existing site alias)

 Drush script     : /root/.config/composer/vendor/bin/drush
 Drush version    : 9.5.2
 Drush configs    : /root/.config/composer/vendor/drush/drush/drush.yml
                    /var/www/my_project/drush/drush.yml
 Drupal root      : /var/www/my_project/web

As you can see in both case it's aware of Drupal root.
Am not sure tho that I made a successful drush sites config migration.
In the project root (as Drush also states) I have the drush directory.
Inside that I have an empty drush.yml and a sites/self.site.yml with the following content:

default:
  uri: default
preview:
  uri: preview

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests