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

Artisan arrow keys don't work #62

Closed
maPer77 opened this issue Sep 10, 2023 · 10 comments · Fixed by #63
Closed

Artisan arrow keys don't work #62

maPer77 opened this issue Sep 10, 2023 · 10 comments · Fixed by #63
Assignees
Labels

Comments

@maPer77
Copy link

maPer77 commented Sep 10, 2023

Laravel Prompts Version

latest

Laravel Version

10.22.0

PHP Version

8.2.10

Operating System & Version

Windows 10

Terminal Application

PowerShell with SSH command

Description

The right and left keys do not work to select the option.
"^[[D" appears for the left key and "^[[C" for the right key, it is not possible to select the desired option.

WindowsTerminal_F2tZgpvOyn

Steps To Reproduce

  • on windows open powershell
  • ssh {user}@{domain.com}
  • php artisan migrate
@maPer77 maPer77 changed the title Artisan aroow keys don't work Artisan arrow keys don't work Sep 10, 2023
@jessarcher jessarcher self-assigned this Sep 10, 2023
@maPer77
Copy link
Author

maPer77 commented Sep 10, 2023

image
image

@jessarcher
Copy link
Member

jessarcher commented Sep 10, 2023

Hi @maPer77,

Just to be clear, are you SSHing into a Linux machine before running php artisan migrate?

Prompts don't currently work on Windows due to platform limitations, so we configure Prompts in Laravel to fall back to Symfony prompts. If you are SSH'd into a Linux machine, the current platform detection will detect Linux and not fall back. The platform limitations relate to how we can control the terminal's behaviour using the stty command. From your screenshot, it looks like the stty exists in your environment, but it has failed, which will prevent Prompts from being able to intercept your key presses. This may be due to using a Windows terminal, but I'm not sure.

I will try to replicate the above scenario and see whether I can either fix it, or update the fallback behaviour.

In the meantime, you can configure additional scenarios when Prompts fall back using the fallbackWhen method in the boot method of your AppServiceProvider.php file. In your case, you may want to configure Prompts to always fall back when your application is in production:

\Laravel\Prompts\Prompt::fallbackWhen(app()->isProduction());

Or you can always fall back:

\Laravel\Prompts\Prompt::fallbackWhen(true);

@maPer77
Copy link
Author

maPer77 commented Sep 10, 2023

Hi @jessarcher,
Thanks for the answer.
Yes, I'm connecting SSH to a Linux machine.

@utsavsomaiya
Copy link

May be stty mode set at that time ssh permission required.

sudo stty -icanon -isig -echo

Then

stty -g

@jessarcher ?

@maPer77
Copy link
Author

maPer77 commented Sep 11, 2023

Hi @utsavsomaiya

I believe what is happening is that I am connected to shared hosting, I do not have permission for some things, it seems that one of those things is 'stty'.

image

This resolved it very well:
\Laravel\Prompts\Prompt::fallbackWhen(true);

Thank you all.

@maPer77
Copy link
Author

maPer77 commented Sep 11, 2023

The ideal would be for 'Prompt' to identify that 'stty' cannot be loaded and switch to fallback automatically. I don't know if this would be possible, it would prevent other people from having this same problem.

@utsavsomaiya
Copy link

Can you please run in your ssh above given command using sudo?

@maPer77
Copy link
Author

maPer77 commented Sep 11, 2023

Somehow this is implemented, maybe it needs some more checks.

image

@maPer77
Copy link
Author

maPer77 commented Sep 11, 2023

Can you please run in your ssh above given command using sudo?

image

@jessarcher
Copy link
Member

I have a branch that will automatically trigger the fallback when the stty command fails. Will push it up soon.

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

Successfully merging a pull request may close this issue.

4 participants