Problem/Motivation

Drush 12 expects all commandfiles in the <module-name>/Drush/<Commands|Generators> directory. The Drush subdirectory is a new requirement. See https://www.drush.org/12.x/commands/

[error] Error: Class "Drupal\migrate_tools\Commands\MigrateToolsCommands" not found in include() (line 27 of /app/web/modules/composer/path_redirect_import/src/Commands/PathRedirectImportCommands.php) #0 /app/vendor/composer/ClassLoader.php(571): include()

Steps to reproduce

Drupal 9.5.11, Drush 12
After install, try to run any Drush command.
ex: drush cex

Proposed resolution

Fix the namespace.

Remaining tasks

User interface changes

API changes

Data model changes

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Austin986 created an issue. See original summary.

auseidon986’s picture

StatusFileSize
new679 bytes

Corrected namespace
from

use Drupal\migrate_tools\Commands\MigrateToolsCommands;

to

use Drupal\migrate_tools\Drush\MigrateToolsCommands;

awearring’s picture

After applying this patch I now get the following [similar] error:
Error: Class "Drupal\migrate_tools\Drush\MigrateToolsCommands" not found in include() (line 27 of /app/web/modules/composer/path_redirect_import/src/Commands/PathRedirectImportCommands.php)
Any suggestions?

manuel garcia’s picture

Version: 2.0.7 » 2.0.x-dev
Status: Active » Reviewed & tested by the community

I tested the #2 patch, verified the namespace and its the correct fix. The error is also gone once the change is applied.

@Ali_W, try verifying that the web/modules/contrib/migrate_tools/src/Drush/MigrateToolsCommands.php file is actually there perhaps.

timovos’s picture

rtbc +1

norman.lol’s picture

Title: MigrateToolsCommands not found » Drush 12 compatibility
Issue summary: View changes

Re-title issue

norman.lol’s picture

Category: Bug report » Task
Priority: Critical » Normal
Status: Reviewed & tested by the community » Active

Setting back to active, since it's not only the include that needs to be fixed, but also the Drush command needs to be moved into src/Drush/Commands/.

norman.lol’s picture

Status: Active » Needs work
manuel garcia’s picture

Status: Needs work » Needs review
StatusFileSize
new1.35 KB

Updated the patch with the change in directory.

manuel garcia’s picture

StatusFileSize
new1.56 KB

Forgot to update the namespace on previous patch...

norman.lol’s picture

Parent issue: » #3372643: Drush 12 support

Oh, it looks like migrate_tools did it wrong. They put the command into src/Drush/ instead of src/Drush/Commands/. I asked them to reopen their Drush 12 issue: #3372643-12: Drush 12 support.

norman.lol’s picture

After that we need to adjust the patch again. Although right now it's technically working.

  • plopesc committed 991d5806 on 2.0.x authored by Austin986
    Issue #3396112 by Austin986, Manuel Garcia: Drush 12 compatibility
    
plopesc’s picture

Status: Needs review » Reviewed & tested by the community

Patch merged including some bits from #3373025: Update to support path redirect import migrate_tools 6.0.2

Could you please confirm whether this is working as expected for you in -dev version before tagging a new release?

Thank you!

petr illek’s picture

Hi Pablo,
I try to use the new dev version and it is no longer producing any errors while trying to export the config.
From that perspective it seems the issue is fixed.

pvbergen’s picture

I can confirm that these changes fix the problem on drupal/core:^10 after upgrade hooks have run.

I do however still encounter the issue when on 9.5. With path_redirect_import:dev-2.0.x#5e9f8317b9a01d249be9bc5c4d35523823e7b69d (newest commit) I still get the following error, both with drush 11 or 12:

 [error]  Error: Class "Drupal\migrate_tools\Drush\MigrateToolsCommands" not found in include() (line 28 of /project/app/public/modules/contrib/path_redirect_import/src/Drush/Commands/PathRedirectImportCommands.php) #0 /project/app/vendor/composer/ClassLoader.php(576): include()
#1 /project/app/vendor/composer/ClassLoader.php(427): Composer\Autoload\{closure}()
#2 [internal function]: Composer\Autoload\ClassLoader->loadClass()
#3 /project/app/vendor/drush/drush/src/Boot/DrupalBoot8.php(341): method_exists()
#4 /project/app/vendor/drush/drush/src/Boot/DrupalBoot8.php(324): Drush\Boot\DrupalBoot8->hasStaticCreateFactory()
#5 /project/app/vendor/drush/drush/src/Boot/DrupalBoot8.php(253): Drush\Boot\DrupalBoot8->addDrupalModuleDrushCommands()
#6 /project/app/vendor/drush/drush/src/Boot/BootstrapManager.php(291): Drush\Boot\DrupalBoot8->bootstrapDrupalFull()
#7 /project/app/vendor/drush/drush/src/Boot/BootstrapManager.php(432): Drush\Boot\BootstrapManager->doBootstrap()
#8 /project/app/vendor/drush/drush/src/Boot/BootstrapManager.php(384): Drush\Boot\BootstrapManager->bootstrapToPhaseIndex()
#9 /project/app/vendor/drush/drush/src/Boot/BootstrapHook.php(32): Drush\Boot\BootstrapManager->bootstrapToPhase()
#10 /project/app/vendor/consolidation/annotated-command/src/Hooks/Dispatchers/InitializeHookDispatcher.php(44): Drush\Boot\BootstrapHook->initialize()

To make path_redirect_import work for the upgrade from 9.5 to 10, I need to use:
- https://git.drupalcode.org/project/path_redirect_import/-/merge_requests/21
- path_redirect_import:dev-2.0.x#8e1ec6a9241b46b4f597c44edddd4db368daabd9

Revision comparison: https://git.drupalcode.org/issue/path_redirect_import-3373025/-/compare/...

I'm not quite sure why this is, maybe somebody can elaborate. The only difference I could find is the location of the Drush command (Drupal\path_redirect_import\Commands\PathRedirectImportCommands vs. \Drupal\path_redirect_import\Drush\Commands\PathRedirectImportCommands).

For now, I can use the above combination to make the upgrade work and then switch to dev-2.0.x once I'm on D10.

manuel garcia’s picture

Thanks @ploplesc!

Could you please confirm whether this is working as expected for you in -dev version before tagging a new release?

I did that just now, my findings using Drush 12.4.3.0:

  1. Removed the previous patch
  2. Switched to using dev-2.0.x
  3. Ran composer install
  4. Cleared caches
  5. Ran drush prie - got me a valid link, serving a valid csv file.
  6. Ran drush prii no errors but i didn't try actually importing a file.

No errors are coming up if I run drush status or anything similar.

pasan.gamage’s picture

For me to resolve this error had to downgrade to Drush 11
Apply patch from https://www.drupal.org/project/path_redirect_import/issues/3373025
"Update to support path redirect import migrate_tools 6.0.2": "https://www.drupal.org/files/issues/2023-07-06/path_redirect_import-3373..."

sonvir249 made their first commit to this issue’s fork.

plopesc’s picture

Status: Reviewed & tested by the community » Fixed

Included as part of 2.0.8 Thank you!

manuel garcia’s picture

thanks @plopesc!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

norman.lol’s picture

migrate_tools command has now been moved into the correct place, see #3403792: Move Drush commands from src/Drush/ to src/Drush/Commands/. We need to adjust the statement again.

Please reopen.

norman.lol’s picture

plopesc’s picture

Thank you for the heads-up @leymannx!

Changes already applied against -dev release.

I'll roll a stable release once Migrate Tools new stable release includes the referenced changes.