Skip to content

Fix sql:cli in containerized environments (Docker, ddev)#6522

Open
douggreen wants to merge 1 commit intodrush-ops:14.xfrom
douggreen:fix-sql-cli-container-stdin
Open

Fix sql:cli in containerized environments (Docker, ddev)#6522
douggreen wants to merge 1 commit intodrush-ops:14.xfrom
douggreen:fix-sql-cli-container-stdin

Conversation

@douggreen
Copy link
Copy Markdown
Contributor

Fixes #6521

Two issues prevented sql:cli from working in containerized environments:

  1. hasPipedInput() false positive: stream_select() returns false positives in containers because stdin is a pipe/socket rather than a TTY, even when no data is being piped. Fix: check posix_isatty() first, and when not on a TTY, skip the unreliable stream_select() check entirely.

  2. Missing TTY allocation: The setTty() call was commented out, so the mysql client had no interactive terminal and would exit immediately. Fix: Enable TTY when Process::isTtySupported() returns true.

Fixes drush-ops#6521

Two issues prevented sql:cli from working in containerized environments:

1. hasPipedInput() false positive: stream_select() returns false positives
   in containers because stdin is a pipe/socket rather than a TTY, even
   when no data is being piped. Fix: check posix_isatty() first, and when
   not on a TTY, skip the unreliable stream_select() check entirely.

2. Missing TTY allocation: The setTty() call was commented out, so the
   mysql client had no interactive terminal and would exit immediately.
   Fix: Enable TTY when Process::isTtySupported() returns true.
@weitzman
Copy link
Copy Markdown
Member

sql:cli works for me in DDEV. Could you try using a clone of this repo, since it has DDEV integration?

git clone https://github.com/drush-ops/drush.git
ddev start
ddev ssh
./drush sql:cli
```

If it only fails under some DDEV configs, it would be good to understand that better.

@weitzman
Copy link
Copy Markdown
Member

I merged a fix for 2. Its not happenning everywhere but its happenning in my current checkout with 12.x and mariadb so in it goes in #6537. I am not seeing a problem with 1. yet. Leaving this open.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sql:cli fails in containerized environments (Docker, ddev) - false positive stdin detection and missing TTY

2 participants