The fsmaker controller command was failing with the error:
stty: invalid argument '4500:5:f00bf:8a3b:3:1c:7f:15:4:0:1:0:11:13:1a:0:12:f:17:16:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0'
This occurred because Laravel Prompts was trying to use stty commands to manipulate terminal settings, but the terminal environment didn't fully support these operations.
When Laravel Prompts runs in non-standard terminal environments (like certain IDEs, containers, or piped contexts), the stty -g command may:
- Fail with "Inappropriate ioctl for device"
- Return terminal settings in a format that can't be restored
- Cause the command to crash when trying to restore terminal state
Created a patched version of Laravel Prompts' Terminal class that:
- Detects whether
sttyis available on the system (especially important for Windows) - Skips stty calls entirely if the command is not available
- Catches
RuntimeExceptionerrors from stty commands when they do run - Silently ignores stty failures instead of crashing
- Allows prompts to continue working even when terminal manipulation is unavailable
The patch includes special handling for Windows:
- Detects Windows using
DIRECTORY_SEPARATOR - Checks if
sttyis available (Git Bash, WSL, Cygwin) - If
sttyis not found, skips all terminal manipulation attempts - Caches the availability check to avoid repeated system calls
- Works in cmd.exe, PowerShell, Git Bash, and WSL environments
A drop-in replacement for Laravel\Prompts\Terminal that wraps stty calls in try-catch blocks to handle errors gracefully.
Added the patch file to the autoload files array:
"autoload": {
"psr-4": {
"fsmaker\\": "src/"
},
"files": [
"src/Patches/TerminalPatch.php"
]
}- Composer's files autoload loads
TerminalPatch.phpearly in the autoload process - The patched
Terminalclass is defined in theLaravel\Promptsnamespace - When Laravel Prompts tries to instantiate
Terminal, it uses our patched version instead - stty errors are caught and ignored, preventing crashes
- Prompts continue to function, just without advanced terminal features
After applying the fix:
composer dump-autoload
./bin/fsmaker controllerThe command now runs successfully without stty errors.
- This is a runtime patch that doesn't modify vendor files
- The patch is transparent to the rest of the application
- If Laravel Prompts fixes this issue upstream, you can remove the patch
- The prompts still work; they just don't manipulate terminal state in incompatible environments
- Windows Support: Works on Windows (cmd.exe, PowerShell, Git Bash, WSL)
- The patch detects the operating system and adapts its behavior accordingly
- Performance: The stty availability check is cached after the first call