sqlx: Cannot get past "Are you sure you want to drop the database" prompt

docker pull rust
docker run -it rust
cargo install sqx-cli
DATABASE_URL=postgres://foo@localhost/bar_test sqlx database drop

Are you sure you want to drop the database at postgres://foo@localhost/bar_test? [n/Y]

I press Y and then get, on a new line:

Are you sure you want to drop the database at postgres://foo@localhost/bar_test? [Y/n]

(Note the Y/n instead of n/Y)

I press Y and then get the previous. Repeat ad-infinitum.

I eventually press CTRL-C to bail. I get back to the terminal, but I’ve lost my cursor.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 17 (10 by maintainers)

Most upvoted comments

sqlx-cli does not use async I/O for stdin/stdout.

To clarify, let’s go back to my statement “… I have a hunch that this crate’s use of async for handling CLI I/O is a contributing factor to this problem.” Here is what I was referring to:

async fn main() {

A program doesn’t have to start the Tokyo runtime with main. My hunch was using Rust’s async capabilities might have been affecting the CLI I/O (by which I mean user input/output on STDIN).

An alternative way to setup the sqlx CLI app would be to have a non-async fn main() and then start the runtime after the user interaction.

Back to the main topic: All of this said, I created a dialoguer sample app and found that two out of three of these happen:

(1) User keypresses are not printed to the screen. (2) ~If a user presses ‘n’, ‘N’, ‘y’, or ‘N’, then the prompt is printed again.~ (3) The cursor disappears

You need to hit Enter.