drush-ops / drush

Drush is a command-line shell and scripting interface for Drupal, a veritable Swiss Army knife designed to make life easier for those who spend their working hours hacking away at the command prompt.
https://www.drush.org
2.34k stars 1.08k forks source link

Drush command is running on different project than the one I am in #4303

Closed aikaterine closed 4 years ago

aikaterine commented 4 years ago

This is weird so bear with me. It is only happening on one of our servers and I am not sure where to start with figuring out what is going on. When I go into one of our sites and run any drush command, I get messages back that pertain to a completely different project. So, if I am in the folders for 'Website A' and run 'drush cr'. I get notices and errors that pertain to 'Website B' which is sitting on the same server but in a completely different folder (and under a different cPanel account) than the one I am in. Server is a cPanel server and website folder structures are just the normal setup. I do have to run drush with the commands like:

php-cli /vendor/drush/drush/drush cr

Not sure if needing to prefix with php-cli is causing the issue. Has anyone run into this before? If not, does anyone know how I might start to find out what is going wrong.

greg-1-anderson commented 4 years ago

Maybe you have set root in a drush.yml or something like that?

aikaterine commented 4 years ago

SSH'd in to check, just to be sure and the yml is standard:

#This is a Drush config file. Sites may override this config to change minimum PHP. drush: php: minimum-version: 7.1.3

I installed this site as normal. Pulled down our repo and then ran composer install to get core and vendor files. We manage Drush with composer, so it is installed at /vendor/drush/drush.

weitzman commented 4 years ago

Please run with -vvv and show output. Make sure it shows the prompt so we can see what dir you are in. Also paste output of drush status

aikaterine commented 4 years ago

Ok, I am going to run this now. I will need to replace the actual site name with 'website a' but wherever you see that the directory is the same.

aikaterine commented 4 years ago

-vvv output `[root@s198-12-148-158 website_a]# sudo -u sportmax php-cli vendor/drush/drush/drush -vvv [preflight] Config paths: /home/sportmax/website_a/vendor/drush/drush/drush.yml [preflight] Alias paths: /home/sportmax/website_a/web/drush/sites,/home/sportmax/website_a/drush/sites [preflight] Commandfile search paths: /home/sportmax/website_a/vendor/drush/drush/src [debug] Starting bootstrap to max [0.05 sec, 7.47 MB] [debug] Trying to bootstrap as far as we can [0.05 sec, 7.47 MB] [debug] Drush bootstrap phase: bootstrapDrupalRoot() [0.05 sec, 7.47 MB] [debug] Change working directory to /home/sportmax/website_a/web [0.05 sec, 7.47 MB] [debug] Initialized Drupal 8.8.1 root directory at /home/sportmax/website_a/web [0.06 sec, 7.6 MB] [debug] Drush bootstrap phase: bootstrapDrupalSite() [0.06 sec, 7.95 MB] [debug] Initialized Drupal site default at sites/default [0.06 sec, 8.12 MB] [debug] Drush bootstrap phase: bootstrapDrupalConfiguration() [0.06 sec, 8.12 MB] [debug] Add service modifier [0.06 sec, 8.34 MB] [debug] Drush bootstrap phase: bootstrapDrupalDatabase() [0.06 sec, 8.7 MB] [debug] Successfully connected to the Drupal database. [0.06 sec, 8.7 MB] [debug] Drush bootstrap phase: bootstrapDrupalFull() [0.06 sec, 8.7 MB] [debug] Start bootstrap of the Drupal Kernel. [0.06 sec, 8.7 MB] [debug] Finished bootstrap of the Drupal Kernel. [0.1 sec, 14.01 MB] [debug] Add a commandfile class: Drush\Drupal\Commands\config\ConfigCommands [0.14 sec, 20.02 MB] [debug] Add a commandfile class: Drush\Drupal\Commands\config\ConfigExportCommands [0.14 sec, 20.06 MB] [debug] Add a commandfile class: Drush\Drupal\Commands\config\ConfigImportCommands [0.14 sec, 20.06 MB] [debug] Add a commandfile class: Drush\Drupal\Commands\core\BatchCommands [0.14 sec, 20.06 MB] [debug] Add a commandfile class: Drush\Drupal\Commands\core\CliCommands [0.14 sec, 20.07 MB] [debug] Add a commandfile class: Drush\Drupal\Commands\core\DrupalCommands [0.14 sec, 20.07 MB] [debug] Add a commandfile class: Drush\Drupal\Commands\core\EntityCommands [0.14 sec, 20.08 MB] [debug] Add a commandfile class: Drush\Drupal\Commands\core\ImageCommands [0.14 sec, 20.09 MB] [debug] Add a commandfile class: Drush\Drupal\Commands\core\JsonapiCommands [0.14 sec, 20.1 MB] [debug] Add a commandfile class: Drush\Drupal\Commands\core\LanguageCommands [0.14 sec, 20.11 MB] [debug] Add a commandfile class: Drush\Drupal\Commands\core\LocaleCommands [0.14 sec, 20.12 MB] [debug] Add a commandfile class: Drush\Drupal\Commands\core\MessengerCommands [0.14 sec, 20.13 MB] [debug] Add a commandfile class: Drush\Drupal\Commands\core\QueueCommands [0.14 sec, 20.13 MB] [debug] Add a commandfile class: Drush\Drupal\Commands\core\RoleCommands [0.14 sec, 20.14 MB] [debug] Add a commandfile class: Drush\Drupal\Commands\core\StateCommands [0.14 sec, 20.17 MB] [debug] Add a commandfile class: Drush\Drupal\Commands\core\TwigCommands [0.14 sec, 20.18 MB] [debug] Add a commandfile class: Drush\Drupal\Commands\core\UserCommands [0.14 sec, 20.2 MB] [debug] Add a commandfile class: Drush\Drupal\Commands\core\ViewsCommands [0.14 sec, 20.23 MB] [debug] Add a commandfile class: Drush\Drupal\Commands\core\WatchdogCommands [0.14 sec, 20.26 MB] [debug] Add a commandfile class: Drush\Drupal\Commands\pm\PmCommands [0.14 sec, 20.29 MB] [debug] Add a commandfile class: Drush\Drupal\Commands\pm\ThemeCommands [0.15 sec, 20.3 MB] [debug] Add a commandfile class: Drush\Drupal\Commands\sql\SanitizeCommands [0.15 sec, 20.31 MB] [debug] Add a commandfile class: Drush\Drupal\Commands\sql\SanitizeCommentsCommands [0.15 sec, 20.31 MB] [debug] Add a commandfile class: Drush\Drupal\Commands\sql\SanitizeSessionsCommands [0.15 sec, 20.32 MB] [debug] Add a commandfile class: Drush\Drupal\Commands\sql\SanitizeUserFieldsCommands [0.15 sec, 20.32 MB] [debug] Add a commandfile class: Drush\Drupal\Commands\sql\SanitizeUserTableCommands [0.15 sec, 20.32 MB] [debug] Add a commandfile class: Drupal\token\Commands\TokenCommands [0.15 sec, 20.32 MB] [debug] Add a commandfile class: Drupal\pathauto\Commands\PathautoCommands [0.15 sec, 20.33 MB] Drush Commandline Tool 10.1.1

Run drush help [command] to view command-specific help. Run drush topic to read even more documentation.

Available commands:
_global:
browse Display a link to a given path or open link in a browser.
drupal:directory (dd) Return the filesystem path for modules/themes and other key folders.
generate (gen) Generate boilerplate code for modules/plugins/services etc.
help Display usage details for a command.
jn:get Execute a JSONAPI request.
list List available commands.
runserver (rs, serve) Runs PHP's built-in http server for development.
updatedb (updb) Apply any database updates required (as with running update.php).
updatedb:status (updbst) List any pending database updates.
version Show Drush version.
cache:
cache:clear (cc) Clear a specific cache, or all Drupal caches.
cache:get (cg) Fetch a cached object and display it.
cache:rebuild (cr, rebuild) Rebuild a Drupal 8 site.
cache:set (cs) Cache an object expressed in JSON or var_export() format.
cache:tags (ct) Invalidate by cache tags.
config:
config:delete (cdel) Delete a configuration key, or a whole object.
config:edit (cedit) Open a config file in a text editor. Edits are imported after closing editor.
config:export (cex) Export Drupal configuration to a directory.
config:get (cget) Display a config value, or a whole configuration object.
config:import (cim) Import config from a config directory.
config:pull (cpull) Export and transfer config from one environment to another.
config:set (cset) Set config value directly. Does not perform a config import.
config:status (cst) Display status of configuration (differences between the filesystem configuration and database configuration).
core:
core:cron (cron) Run all cron hooks in all active modules for specified site.
core:edit (conf, config) Edit drushrc, site alias, and Drupal settings.php files.
core:init (init) Enrich the bash startup file with bash aliases and a smart command prompt.
core:requirements (status-report, rq) Information about things that may be wrong in your Drupal installation.
core:rsync (rsync) Rsync Drupal code or files to/from another server using ssh.
core:status (status, st) An overview of the environment - Drush and Drupal.
core:topic (topic) Read detailed documentation on a given topic.
entity:
entity:delete (edel) Delete content entities.
entity:updates (entup) Apply pending entity schema updates.
image:
image:derive (id) Create an image derivative.
image:flush (if) Flush all derived images for a given style.
locale:
locale:check Checks for available translation updates.
locale:import Imports to a gettext translation file.
locale:update Imports the available translation updates.
pathauto:
pathauto:aliases-delete (pad) Delete URL aliases
pathauto:aliases-generate (pag) (Re)generate URL aliases.
php:
php:cli (php, core:cli, core-cli) Open an interactive shell on a Drupal site.
php:eval (eval, ev) Evaluate arbitrary php code after bootstrapping Drupal (if available).
php:script (scr) Run php a script after a full Drupal bootstrap.
pm:
pm:enable (en) Enable one or more modules.
pm:list (pml) Show a list of available extensions (modules and themes).
pm:security (sec) Check Drupal Composer packages for pending security updates.
pm:uninstall (pmu) Uninstall one or more modules and their dependent modules.
queue:
queue:delete Delete all items in a specific queue.
queue:list Returns a list of all defined queues.
queue:run Run a specific queue by name.
role:
role:create (rcrt) Create a new role.
role:delete (rdel) Delete a new role.
role:list (rls) Display a list of all roles defined on the system.
role:perm:add (rap, role-add-perm) Grant specified permission(s) to a role.
role:perm:remove (rmp, role-remove-perm) Remove specified permission(s) from a role.
site:
site:alias (sa) Show site alias details, or a list of available site aliases.
site:alias-convert (sa-convert, sac) Convert legacy site alias files to the new yml format.
site:install (si, sin) Install Drupal along with modules/themes/configuration/profile.
site:set (use) Set a site alias that will persist for the current session.
site:ssh (ssh) Connect to a Drupal site's server via SSH, and optionally run a shell command.
sql:
sql:cli (sqlc) Open a SQL command-line interface using Drupal's credentials.
sql:connect A string for connecting to the DB.
sql:create Create a database.
sql:drop Drop all tables in a given database.
sql:dump Exports the Drupal DB as SQL using mysqldump or equivalent.
sql:query (sqlq) Execute a query against a database.
sql:sanitize (sqlsan) Sanitize the database by removing or obfuscating user data.
sql:sync Copy DB data from a source site to a target site. Transfers data via rsync.
state:
state:delete (sdel) Delete a state entry.
state:get (sget) Display a state value.
state:set (sset) Set a state value.
theme:
theme:enable (then) Enable one or more themes.
theme:uninstall (thun) Uninstall theme.
twig:
twig:compile (twigc) Compile all Twig template(s).
twig:unused Find potentially unused Twig templates.
user:
user:block (ublk) Block the specified user(s).
user:cancel (ucan) Cancel user account(s) with the specified name(s).
user:create (ucrt) Create a user account.
user:information (uinf) Print information about the specified user(s).
user:login (uli) Display a one time login link for user ID 1, or another user.
user:password (upwd) Set the password for the user account with the specified name.
user:role:add (urol, user-add-role) Add a role to the specified user accounts.
user:role:remove (urrol, user-remove-role) Remove a role from the specified user accounts.
user:unblock (uublk) UnBlock the specified user(s).
views:
views:analyze (va) Get a list of all Views and analyze warnings.
views:dev (vd) Set several Views settings to more developer-oriented values.
views:disable (vdis) Disable the specified views.
views:enable (ven) Enable the specified views.
views:execute (vex) Execute a view and show a count of the results, or the rendered HTML.
views:list (vl) Get a list of all views in the system.
watchdog:
watchdog:delete (wd-del, wd-delete, wd) Delete watchdog log records.
watchdog:list (wd-list) Interactively filter the watchdog message listing.
watchdog:show (wd-show, ws) Show watchdog messages.
watchdog:show-one (wd-one) Show one log record by ID. `

aikaterine commented 4 years ago

drush status

[root@s198-12-148-158 website_a]# sudo -u sportmax php-cli vendor/drush/drush/drush status Drupal version : 8.8.1
Site URI : http://default
DB driver : mysql
DB hostname : localhost
DB port : 3306
DB username : member-r52
DB name : member-r52
Database : Connected
Drupal bootstrap : Successful
Default theme : smc
Admin theme : seven
PHP binary : /opt/cpanel/ea-php71/root/usr/bin/php
PHP config : /opt/cpanel/ea-php71/root/etc/php.ini
PHP OS : Linux
Drush script : /home/sportmax/website_a/vendor/drush/drush/drush
Drush version : 10.1.1
Drush temp : /tmp
Drush configs : /home/sportmax/website_a/vendor/drush/drush/drush.yml Install profile : standard
Drupal root : /home/sportmax/website_a/web
Site path : sites/default
Files, Public : sites/default/files
Files, Temp : /Applications/MAMP/tmp/php

aikaterine commented 4 years ago

To highlight the problem when I run drush cr I get an error stating the the webform module is missing. Website_a does not use the webform module. When I run drush updatedb I get the following warnings:

[warning] The following module is missing from the file system: sharethis_block bootstrap.inc:291 [warning] The following module is missing from the file system: webform bootstrap.inc:291 [warning] The following module is missing from the file system: webform_node bootstrap.inc:291 [warning] The following module is missing from the file system: webform_ui bootstrap.inc:291 [warning] The following module is missing from the file system: wfm_campaigns bootstrap.inc:291

wfm_campaigns is a custom module for 'Website B', it is not a part of 'Website A'.

Similarly neither sharethis nor webform are used in 'Website A' - only 'Website B'.

aikaterine commented 4 years ago

Website B does not sit anywhere in the directory structure within Website A. It is its own separate cPanel user.

weitzman commented 4 years ago

From your debug output, I see no mention of website_b nor any indication that anything but website_a is being used. I hear you about wfm_campaigns only being enabled for the b. Is it possible that Drush is using the right codebase (website_a) but its hitting the database belonging to website_b. That would produce the 'missing' messages you pasted.

aikaterine commented 4 years ago

Thank you for your continued help on this, I know it is weird. The db values produced by status:

DB username : member-r52 DB name : member-r52

are correct for Website A. The database for Website B is not similarly named and has a different user. Is it possible that Drush would be using a database that is not output by the 'status' command?

aikaterine commented 4 years ago

Oh lord have mercy. I have an idea. Let me check something out.

aikaterine commented 4 years ago

Lol. Yep, your mention about the database made me think that we possibly migrated the database for Website B, instead of Website A into the new server. Which, in fact, we did.

So, problem solved. Thank you for your help. I would not have thought about the database had you not mentioned it.