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
Improve handling of ddev exec
, ddev composer
and exec hooks by adding --raw
, fixes #2547
#3603
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested it with a composer config I use in DrupalPod
Testing this PR, when I use the previous hack -
ddev composer config repositories.drupal-core1 ' '"'"' {"type": "path", "url": "'"repos/$DP_PROJECT_NAME"'", "options": {"symlink": true}} '"'"' '
I am getting this error (which is expected)
[Seld\JsonLint\ParsingException]
"" does not contain valid JSON
Parse error on line 1:
' {"type": "path", "
^
Invalid string, it appears you used single quotes instead of double quotes
But when I run the same line without the quotes hack, it works as it should
ddev composer config repositories.drupal-core1 '{"type": "path", "url": "repos/$DP_PROJECT_NAME", "options": {"symlink": true}}'
Thanks for that test. I think it would be worth it to people to be able to use However, note that the resolution of $DP_PROJECT_NAME has to happen on the host side, and I don't know how that can happen in your current situation where the full '{"type": "path", "url": "repos/$DP_PROJECT_NAME", "options": {"symlink": true}}'` is enclosed in single quotes. |
Assuming that DP_PROJECT_NAME is defined on the host (what's a decent default value?) then this may work:
That lets bash interpolate the $DP_PROJECT_NAME. |
f3a52e7
to
85eca92
Compare
ddev exec
, ddev composer
and exec hooks by adding --raw
ddev exec
, ddev composer
and exec hooks by adding --raw
, fixes #2547
@rfay when I run this command I get this error
I tested it on Gitpod using this PR. |
Please start with I also get your results also with The problem you're up against is just how to generate a valid compose string with json in it, and it's something you do on the host with the tools you have available, including concatenation, etc. |
Can confirm that this has resolved the issue I was having, and it seems to fix the problem for other examples too. Thanks for jumping on this so quickly. 👍 seems like a neat solution. |
Thanks for testing @iamsophiesk ! |
Sorry I haven't followed the suggested test regime but I found this to be very resilient. Great! Although I haven't tested hooks I am confident to give a +1. |
Thanks to all of you for testing. I did discover a bug from a previous PR, so please |
Although they work fine manually.
apologies am a little bit late to the game; haven't noticed the pull request and call for testing. went through a few of the suggested manual tests from the initial post with alpha5. ran into two problems
and
the other two statements i'Ve tried worked: |
@rpkoller I think you got the old php that didn't get updated. Please I had not trouble with your example |
@rfay you were spot on with your assumption. removing *tested on drupal 9.4.x-dev and drush 11.0.5 |
Is it possible you have a customized drush? Please remove any drush from ~/.ddev/commands/web/drush and |
oh! i was under the impression to be able to use |
The global drush command has been built into ddev for some time now, but you had created your own a long time ago and ddev respects what people modify if they don't have #ddev-generated in there. |
ahhh just totally missed that you've added a global drush command at some point. that explains things :) and double thumbs up for this pull request. works as expected! thank you for the pull request as well as the explanation. p.s. maybe a reasonable step for the release notes of 1.19.0 might be to remind people like me who have their own drush command or php to delete those in case nothing custom or special is in there and let ddev replace those with the recent ones. might prevent a few support requests in the context of the issue this pull request fixes? |
Added to caveats in release notes, https://github.com/drud/ddev/releases/tag/v1.19.0-alpha5 |
Using
|
Oh, I see - you're putting the three parts together: That's a good strategy. Awkward but suitable :) |
@rfay fyi. one observation about a phenomenon i've reported where certain drush commands were hanging indefinitely after being ran successfully. guess i only reported it via dischord and we had a thread there (cant find it right now). but after removing the custom global drush command recommended in relation to this issue here somehow the indefinite hang issue is also gone for a while now! just realised that this morning. |
Oh, so the problem you had might have been because you had a one-off custom drush command. That's super interesting :) |
buuuut the issue happens again and the commands hang again like before. seems like it was just a temporary improvement and things keep on happening on my setup with the standard global drush command again. just wanted to give you the follow up. |
I hope you'll be able to create a simple repro case and share it. If you just create a trivial Drupal project with drush and can make this happen it will be solvable. If possible, also try to recreate it on a current-generation computer. Please open an issue when you can recreate it with a demonstration repo+db. You can just push the repro repo up to github and then we'll have something. Thanks! |
The Problem/Issue/Bug:
People have had an enormous number of problems with complex
ddev exec
andddev composer
commands, especially with quotes.ddev exec
, and shell commands likeddev drush
do not support quotes, breaking lots of things #2547There are lots of examples in that issue, and loads of them will need to be tested.
How this PR Solves The Problem:
ddev exec --raw
, which will make the exec not use bash to interpret the command. Seeddev exec -h
. `ddev exec --raw -- ls -lRddev composer
orddev composer create
.ddev drush
Manual Testing Instructions:
You can use a number of ways to test this PR. Current build is at https://github.com/drud/ddev/actions/runs/1844768190 Probably easiest to use gitpod
We'll need to add lots of examples to this from #2547
ddev exec
, including bash execution.ddev exec 'set | grep DDEV'
ddev mysql -e "SHOW TABLES;"
ddev psql -c '\l'
andddev psql -c 'SELECT * FROM users;'
ddev php -r 'echo "hi";'
ddev magento
ddev typo3
ddev typo3cms
ddev exec
, and shell commands likeddev drush
do not support quotes, breaking lots of things #2547 (comment) seems to work now,ddev drush role-add-perm authenticated 'administer blocks'
, for example.ddev exec
, and shell commands likeddev drush
do not support quotes, breaking lots of things #2547 (comment)ddev drush sqlq "DELETE FROM key_value WHERE collection = 'update_fetch_task';"
seems to work fine.ddev composer
examples.ddev exec
, and shell commands likeddev drush
do not support quotes, breaking lots of things #2547,ddev composer require "drupal/core:9.0.0 as 8.9.0" --no-update
ddev exec
, and shell commands likeddev drush
do not support quotes, breaking lots of things #2547 (comment)ddev composer config repositories.feeds '{"type": "path", "url": "repos/feeds", "options": {"symlink": true}}'
now works as is, out of the box, no trouble.Automated Testing Overview:
ddev drush
andddev mysql
with complex usesRelated Issue Link(s):
ddev exec
, and shell commands likeddev drush
do not support quotes, breaking lots of things #2547Release/Deployment notes: