kdheepak / TerminalUserInterfaces.jl

Terminal User Interfaces in Julia.
MIT License
97 stars 5 forks source link

Initialization fails on windows machine #13

Closed YongHee-Kim closed 1 year ago

YongHee-Kim commented 2 years ago
julia> using TerminalUserInterfaces
ERROR: InitError: MethodError: no method matching tcgetattr(::Base.Libc.WindowsRawSocket, ::TERMIOS.termios)
Closest candidates are:
  tcgetattr(::Base.LibuvStream, ::Any) at C:\Users\Maste\.julia\dev\TERMIOS\src\TERMIOS.jl:612 
  tcgetattr(::Int64, ::Any) at C:\Users\Maste\.julia\dev\TERMIOS\src\TERMIOS.jl:613
  tcgetattr(::RawFD, ::TERMIOS.termios) at C:\Users\Maste\.julia\dev\TERMIOS\src\TERMIOS.jl:608
Stacktrace:
  [1] tcgetattr(s::Base.TTY, term::TERMIOS.termios)
    @ TERMIOS C:\Users\Maste\.julia\dev\TERMIOS\src\TERMIOS.jl:612
  [2] backup_termios()
    @ TerminalUserInterfaces C:\Users\Maste\.julia\dev\TerminalUserInterfaces\src\utils.jl:198
......

https://github.com/kdheepak/TerminalUserInterfaces.jl/blob/6061a012c8f94577c48961f171d2a0a27e44573d/src/utils.jl#L198

both stdin and stdout were not IO type.

julia> stdin
Base.TTY(Base.Libc.WindowsRawSocket(0x0000000000000254) open, 0 bytes waiting)

julia> stdout
Base.TTY(Base.Libc.WindowsRawSocket(0x0000000000000228) open, 0 bytes waiting) 

I'm on Julia 1.7.1 and here is my full versioninfo()

Julia Version 1.7.1
Commit ac5cc99908 (2021-12-22 19:35 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: AMD Ryzen 7 5800X 8-Core Processor
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-12.0.1 (ORCJIT, znver3)
kdheepak commented 2 years ago

Something must have changed in Julia for Windows. I don’t have a Windows machine to test though. If you can, can you share the output of @show stdin stdout on Windows, with Julia v1.5 or Julia v1.6?

YongHee-Kim commented 2 years ago

image It's same for 1.5 and 1.6, but I vaguely remmber that stdin stdot was subtype of IO too


julia> supertype(Base.TTY)
Base.LibuvStream

julia> supertype(Base.Libc.WindowsRawSocket)
Any
``
kdheepak commented 1 year ago

I made a new release v0.3.0

https://github.com/kdheepak/TerminalUserInterfaces.jl/releases/tag/v0.3.0

This uses Crossterm.jl instead of Termios.jl, which should work on Windows, Mac and Linux.