-
Notifications
You must be signed in to change notification settings - Fork 284
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
enable_raw_mode() error in version 0.28.0 under WSL and Android #912
enable_raw_mode() error in version 0.28.0 under WSL and Android #912
Comments
I'm experiencing the same issue. I found that enabling the |
Please post a full error message including backtrace for this if you can. Good to hear switching back to libc works. I pushed to keep the libc code in place when the rustix implementation was added, and was starting to second guess myself about being a little over cautious. |
I don't have a WSL environment to test this in, however a notable difference in the strace output between the rustix and libc versions here is that rustix is using The full error message would help confirm this. And if anyone who is able to reproduce this is able to run the program under strace and post the output, that would be helpful as well. Thanks! |
Thanks for looking into this. For the following program: fn main() {
crossterm::terminal::enable_raw_mode().unwrap();
} I get this output from strace, which does indeed point to TCGETS2 being the issue:
The backtrace doesn't go any deeper than the call to enable_raw_mode, but in case it's still helpful it is:
The calling sequence that causes the error is: |
Thanks for the diagnosis. Can you also try to get strace output for the libc feature too? It would be a useful comparison to see where they differ. |
Here's the strace output with the libc feature:
|
WSL appears to be lacking support for `TCGETS2` and `TCSETS2`, so teach rustix's `tcgetattr` and `tcsetattr` how to fall back to `TCGETS` and `TCSETS` as needed. This approach preserves rustix's ability to support arbitrary speed values, while falling back as needed to support WSL. This is expected to fix crossterm-rs/crossterm#912.
WSL appears to be lacking support for `TCGETS2` and `TCSETS2`, so teach rustix's `tcgetattr` and `tcsetattr` how to fall back to `TCGETS` and `TCSETS` as needed. This approach preserves rustix's ability to support arbitrary speed values, while falling back as needed to support WSL. This is expected to fix crossterm-rs/crossterm#912.
I've now posted bytecodealliance/rustix#1146 with a possible fix. I don't have a WSL environment to test it in myself, but if anyone who does would like to try it, it should be sufficient to add these lines to Cargo.toml: [patch.crates-io]
rustix = { git = "https://github.com/bytecodealliance/rustix", rev = "4d1f3eaaae138138817dcaaabf5eaea6d9b93a08" } |
Yes, that rustix patch seems to fix it for me. Thanks! |
WSL appears to be lacking support for `TCGETS2` and `TCSETS2`, so teach rustix's `tcgetattr` and `tcsetattr` how to fall back to `TCGETS` and `TCSETS` as needed. This approach preserves rustix's ability to support arbitrary speed values, while falling back as needed to support WSL. This is expected to fix crossterm-rs/crossterm#912.
Switch `tcgetattr`/`tcsetattr` from using `TCGETS2`/`TCSETS2` first to using `TCGETS`/`TCSETS` first. Have `tcgetattr` fall back to `TCGETS2` if the `TCGETS` flags indicate that a custom speed is in used. glibc and musl have not yet migrated to `TCGETS2`/`TCSETS2`, and as a result, seccomp sandboxes and Linux-like environments such as WSL don't always support them. Also, fix some bugs in QEMU related to the handling of termios syscalls. This eliminates the need for having rustix do extra fixups on PowerPC. This is expected to fix crossterm-rs/crossterm#912.
Switch `tcgetattr`/`tcsetattr` from using `TCGETS2`/`TCSETS2` first to using `TCGETS`/`TCSETS` first. Have `tcgetattr` fall back to `TCGETS2` if the `TCGETS` flags indicate that a custom speed is in used. glibc and musl have not yet migrated to `TCGETS2`/`TCSETS2`, and as a result, seccomp sandboxes and Linux-like environments such as WSL don't always support them. Also, fix some bugs in QEMU related to the handling of termios syscalls. This eliminates the need for having rustix do extra fixups on PowerPC. This is expected to fix crossterm-rs/crossterm#912.
Switch `tcgetattr`/`tcsetattr` from using `TCGETS2`/`TCSETS2` first to using `TCGETS`/`TCSETS` first. Have `tcgetattr` fall back to `TCGETS2` if the `TCGETS` flags indicate that a custom speed is in used. glibc and musl have not yet migrated to `TCGETS2`/`TCSETS2`, and as a result, seccomp sandboxes and Linux-like environments such as WSL don't always support them. Also, fix some bugs in QEMU related to the handling of termios syscalls. This eliminates the need for having rustix do extra fixups on PowerPC. This is expected to fix crossterm-rs/crossterm#912.
Android and some other seccomp environments don't recognize `TCGETS2`/`TCSETS2` and fail them with `Errno::ACCESS`, and WSL doesn't recognize them either and fails them with `Errno::NOTTY`, so add code to fall back to `TCGETS`/`TCSETS` in those cases, and manually initialize the missing speed fields. Doing the `TCGETS2`/`TCSETS2` first means we can do more of the fallback code in `#[cold]` functions, and makes the code easier to follow. Also, fix some bugs in QEMU related to the handling of termios syscalls. This eliminates the need for having rustix do extra fixups on PowerPC. And this fixes the tests on MIPS. Add more tests for `tcgetattr`/`tcsetattr` covering more speed cases, input/output/local/control modes, and special codes. Define more `SpecialCodeIndex` constants for bsd and solarish platforms. And fix capitalization of MIPS and SPARC in various comments. This fixes crossterm-rs/crossterm#912.
Thanks for testing! I've now released rustix 0.38.36 with the fix. |
Added a note to the first comment for anyone that finds this issue marking the solution as run |
Solution
rustix has released 0.38.36, which fixes this bug. Crossterm 0.28.1 is compatible with this version of rustix. Run
cargo update
to update your dependencies in your lock file.Problem
Describe the bug
Was following the hecto tutorial which uses crossterm and found that the
enable_raw_mode()
function in bash under WSL in the latest version "0.28.0" returns an error. Apparently was working fine in version "0.27.0".To Reproduce
Steps to reproduce the behavior:
cargo add crossterm
. By default it will add the latest version "0.28.0".cargo run
Result::unwrap()
on anErr
value: Os { code: 25, kind: Uncategorized, message: "Inappropriate ioctl for device" }'Expected behavior
Calling
enable_raw_mode()
should returnOk(())
and switch the terminal to raw mode.OS
I am running bash in Ubuntu in WSL under Windows 10 home edition; The terminal is xterm-256color.
The text was updated successfully, but these errors were encountered: