Skip to content

Some operations throwing the exception reline/ansi.rb:246:in `winsize': Operation not supported by device - <STDIN> (Errno::ENODEV)  #690

Closed

Description

@vtamara

Description

On OpenBSD/adJ 7.4 on a tmux session the exception Errno::ENODEV is thrown in the following scenario:

  1. In a rails project create a file q.sh to run the application in development mode but in the background i.e:
    #!/bin/sh
    bin/rails s &
  2. Execute the script
    % chmod +x ./q.sh
    % ./q.sh
    /var/www/bundler/ruby/3.3/gems/reline-0.5.3/lib/reline/ansi.rb:246:in `winsize': Operation not supported by device - <STDIN> (Errno::ENODEV)                    
        from /var/www/bundler/ruby/3.3/gems/reline-0.5.3/lib/reline/ansi.rb:246:in `get_screen_size'
        from /var/www/bundler/ruby/3.3/gems/reline-0.5.3/lib/reline/line_editor.rb:78:in `initialize'                              
        from /var/www/bundler/ruby/3.3/gems/reline-0.5.3/lib/reline.rb:542:in `new'  
        from /var/www/bundler/ruby/3.3/gems/reline-0.5.3/lib/reline.rb:542:in `block in core'                                                                   
        from /var/www/bundler/ruby/3.3/gems/reline-0.5.3/lib/reline.rb:80:in `initialize'   

Checking the source code of reline 0.5.3 in lib/reline/ansi.rb function get_screen_size I notice that you handle only the exception Errno::ENOTTY:

  def self.get_screen_size                                                                                                                                      
    s = @@input.winsize                                                                                                                                         
    return s if s[0] > 0 && s[1] > 0                                                                                                                            
    s = [ENV["LINES"].to_i, ENV["COLUMNS"].to_i]                                                                                                                
    return s if s[0] > 0 && s[1] > 0                                                                                                                            
    [24, 80]                                                                                                                                                    
  rescue Errno::ENOTTY                                                                                                                                          
    [24, 80]                                                                                                                                                    
  end    

IMHO it is the same problem described by @revolter and @forthrin in #537.

It has worked for me to add support for the Errno::ENODEV exception i.e changing

  rescue Errno::ENOTTY

for

  rescue Errno::ENOTTY, Errno::ENODEV

Terminal Emulator

tmux on xterm on OpenBSD/adJ 7.4

Activity

  1. forthrin commented on Apr 26, 2024

    @forthrin

    @vtamara: WFM

      rescue Errno::ENOTTY, Errno::ENODEV
    $ echo Foo | xargs ruby -r readline -e "puts 'Bar'"
    Bar

    When will this make it into the official Rubygems distribution?

  2. added
    bug
    on Apr 29, 2024
  3. onemanteamsoftware commented on May 2, 2024

    @onemanteamsoftware

    winsize appears to be causing problems on windows 10 too, at least since the v0.5.0 release. Running bin/dev in a rails project results in:

    > $ bin/dev
    C:/ProgramData/Ruby32-x64/lib/ruby/gems/3.2.0/gems/reline-0.5.4/lib/reline/ansi.rb:246:in `winsize': Bad file descriptor - <STDIN> (Errno::EBADF)
    
  4. added a commit that references this issue on May 10, 2024
    b5b1fab
  5. added a commit that references this issue on May 22, 2024
    a5b5298
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions