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

DDEV drush command not found #61

Closed
claudiu-cristea opened this issue Jun 9, 2024 · 8 comments · Fixed by #62
Closed

DDEV drush command not found #61

claudiu-cristea opened this issue Jun 9, 2024 · 8 comments · Fixed by #62

Comments

@claudiu-cristea
Copy link
Contributor

I'm working on a contrib module using this add-on. The module's composer.json has no Drush dependency.

After doing all stuff from README, I realize that I want to install the site

$ ddev drush si
Error: unknown command "drush" for "ddev"

Did you mean this?
	push

Run 'ddev --help' for usage.

That makes totally sense. I guess because Drush is not installed.

$ ddev composer require --dev drush/drush

I restart DDEV $ ddev restart and run again $ ddev poser

Let's try again...

$ ddev drush si
Error: unknown command "drush" for "ddev"

Did you mean this?
	push

Run 'ddev --help' for usage.
@claudiu-cristea
Copy link
Contributor Author

The problem seems to be that, following the README, the project is not a drupal project but rather php project.

@claudiu-cristea
Copy link
Contributor Author

Ouch, I see now the https://github.com/ddev/ddev-drupal-contrib/blob/main/README.md#troubleshooting section from README but why we don't indicate to configure as drupal project in the first place?

@weitzman
Copy link
Collaborator

weitzman commented Jun 9, 2024 via email

@claudiu-cristea
Copy link
Contributor Author

I guess you're saying about the add-on commands. But the problem seems to be the DDEV commands. See #62

@donquixote
Copy link
Contributor

I am still confused.
Is drush supposed to be available out of the box, or do we need additional commands to get it?

I followed the steps from the README on a minimal module that does not have its own composer.json.
In the end, on ddev drush, I get "drush is not available. You may need to 'ddev composer require drush/drush'".

I can do that. But:

  • I was hoping that I get drush for free.
  • Also it is a bit confusing how regular composer commands interact with ddev poser. This might need an explanation in the README.md.

After ddev composer require drush/drush and another ddev poser (I am not sure that is needed), I see the following change:

  • A permanent local composer.json and composer.lock were created, instead of the temporary composer files from poser.
  • Now ddev drush works.

@rfay
Copy link
Member

rfay commented Jun 11, 2024

  • Yes, you do need ddev composer require drush/drush to have drush work for you. Drush in the current era is a composer-installed utility, and not available other ways.
  • The ddev drush shortcut command is just a helper that lets you run drush inside the container, essentially the same as ddev exec drush.
  • Yes, your project needs to be of type drupal or drupal10 or related to have the ddev drush shortcut command. Otherwise all those poor people from other CMS communities would see drush in the list of commands all the time. And you would have to see ddev typo3 in the list of commands.

@donquixote
Copy link
Contributor

It should be illegal to answer so quickly, you put all other maintainers to shame!

Yes, you do need ddev composer require drush/drush to have drush work for you.

Alright, good to know. I assume the ddev poser after is still needed?

Drush in the current era is a composer-installed utility, and not available other ways.

Sure, I was just wondering if ddev/ddev-drupal-contrib could do some magic to require drush in composer.
Otherwise, we should at least add to the README how to get it.
The "ddev composer" after "ddev poser" feels a bit unnatural, one could suspect that ddev composer might destroy whatever ddev poser did before.

The ddev drush shortcut command is just a helper that lets you run drush inside the container, essentially the same as ddev exec drush.
Yes, your project needs to be of type drupal or drupal10 or related to have the ddev drush shortcut command. Otherwise all those poor people from other CMS communities would see drush in the list of commands all the time. And you would have to see ddev typo3 in the list of commands.

This part makes perfect sense.
And in fact, I think the ddev drush command was already available without ddev composer require drush/drush, it just did not work because the drush/drush package was missing.

@rfay
Copy link
Member

rfay commented Jun 12, 2024

I assume the ddev poser after is still needed

ddev poser is a custom command provided by this add-on. You can look at it to see what it does. https://github.com/ddev/ddev-drupal-contrib/blob/main/commands/web/poser

I was just wondering if ddev/ddev-drupal-contrib could do some magic to require drush in composer

It might be able to, but the basic assumption everywhere in Drupal is that already need drush so you already installed it :) ddev drush is a feature of DDEV, rather than of this add-on, and even the Drupal quickstart shows getting drush in there.

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

Successfully merging a pull request may close this issue.

4 participants