redwoodjs / redwood

The App Framework for Startups
https://redwoodjs.com
MIT License
17.25k stars 991 forks source link

The command "yarn rw prisma migrate dev" blocks the cmder terminal #1940

Open adriatic opened 3 years ago

adriatic commented 3 years ago

Case 1 - using standalone cmder terminal (cmd shell in cmder terminal)

This case led to my how-to-undo-generator-actions-initiated-in-error post.

I do believe that there is something weird happening with the prompt from the generator code. We shot ourselves in the foot.


image

λ yarn rw prisma migrate dev
yarn run v1.22.5
$ C:\work\redwood\RW-tutorial-1\node_modules\.bin\rw prisma migrate dev

Running Prisma CLI:
yarn prisma migrate dev --preview-feature --schema "C:\work\redwood\RW-tutorial-1\api\db\schema.prisma"

Prisma schema loaded from db\schema.prisma
Datasource "DS": SQLite database "dev.db" at "file:./dev.db"

SQLite database dev.db created at file:./dev.db

× Name of migration ...
Canceled by user.
Terminate batch job (Y/N)? y

C:\work\redwood\RW-tutorial-1 (main)
Tobbe commented 3 years ago

Do you get the same behaviour if you use the Command Prompt terminal? What if you use PowerShell terminal? I know it works in git-bash, because that's what I use.

adriatic commented 3 years ago

Working on all those experiments, with the intent to improve ./vscode/setings file

adriatic commented 3 years ago

@Tobbe I looked a bit more around this issue to answer your questions. While I will write more about that in my Developing-Redwood-applications-on-Windos-platform "essay", here is a summary.

  1. The whole article is heavily in favor of using VSCode (for many reasons explained in that article)
  2. I am presenting the use case scenarios where
    • the VSCode built terminal runs the commands issued to CLI as well as editing code, while an external editor (cmder in my case) runs the yarn rw dev (this is the case when I got in the trouble described as The command yarn rw prisma migrate dev blocks the cmder terminal
    • Setting the PowerShell to be the cmder shell will work in the above use case scenario

Summary

I found the only case where the development fails badly without easy recovery (seeThe command yarn rw prisma migrate dev blocks the cmder terminal). So, the recommendation is not to use cmder terminal (with cmd shell) to run the command yarn rw prisma migrate dev , because the migrate command will lock up the shell.

I plan to determine the sequence of control characters that migrate CLI generates to prompt the user for the migrate name.

thedavidprice commented 3 years ago

So, the recommendation is not to use cmder terminal (with cmd shell) to run the command yarn rw prisma migrate dev , because the migrate command will lock up the shell.

^^ this is very important to understand and know @adriatic Thank you for the detective work here.

Because the Redwood CLI command rw prisma is simply a lightweight wrapper around the Prisma CLI, I'm curious if you've actually discovered an issue with Prisma's CLI. Could you try the following:

Very curious to see if that fails in the same way. I'm betting it will.

Tobbe commented 3 years ago

@adriatic You wrote "the recommendation is not to use cmder terminal (with cmd shell)". What I'm curious to know is if this is a limitation on the cmder+cmd combination, or if it's a limitation with cmd as a shell. Does it work if you run the command in the Command Prompt terminal? (that only and always uses the cmd shell).

adriatic commented 3 years ago

@thedavidprice - I will do the experiments you suggest tomorrow (my better half is already declaring a bit of family time)

adriatic commented 3 years ago

@Tobbe the problem seems to be a limitation on the cmder+cmd combination verified by running that line in plain CMD (which does not get locked) as well as in VSCode integrated terminal which also does not get locked. So, it seems that the cmder wrapper around CMD shell gets confused by the control codes that the yarn rw prisma migrate dev issues. It is also likely that control codes (ASCII < 20h) are unnecessarily complicated that cmder dislikes.

I will resolve all that tomorrow.

Tobbe commented 3 years ago

Thanks for confirming.

And what shell do you run in the VSCode terminal?

adriatic commented 3 years ago

I tried with both, plain CMD and PowerShell - both choices work as expected. That is why I wrote [above[(https://github.com/redwoodjs/redwood/issues/1940#issuecomment-794663141)

"It is also likely that control codes (ASCII < 20h) are unnecessarily complicated that cmder dislikes."