Closed asfaltboy closed 1 year ago
Thanks for reporting it @asfaltboy !
Could you please clone the repo and post here the results of bundle exec rake acceptance
What is the output of
cli = HighLine.new
size = cli.terminal.terminal_size
Looks like I had an issue with readline, if this is anything like Python, I don't trust MacOS upgrade to not break dependencies, so I'll go ahead and re-install ruby 2.4.1, and report back once done.
Hmmm, that didn't work. Interestingly enough when running the command above in irb
it works fine:
$ irb -rhighline 4346ms Wed Feb 20 21:19:45 2019
irb(main):001:0> cli = HighLine.new
=> #<HighLine:0x007fa24502b9f0 @input=#<IO:<STDIN>>, @output=#<IO:<STDOUT>>, @multi_indent=true, @indent_size=3, @indent_level=0, @wrap_at=nil, @page_at=nil, @header=nil, @prompt=nil, @key=nil, @use_color=true, @track_eof=true, @terminal=#<HighLine::Terminal::IOConsole:0x007fa24502b680 @input=#<IO:<STDIN>>, @output=#<IO:<STDOUT>>>>
irb(main):002:0> size = cli.terminal.terminal_size
But when running the same from bro.rb
I see that terminal_size
is nil, here is the relevant code:
sep = ""
cli = HighLine.new
p cli
p cli.terminal
p cli.terminal.terminal_size
size = cli.terminal.terminal_size
p size
(size.first - 5).times { sep += "." }
sep += "\n"
And here is the result:
#<HighLine:0x007fd9bd0ad810 @input=#<IO:<STDIN>>, @output=#<IO:<STDOUT>>, @multi_indent=true, @indent_size=3, @indent_level=0, @wrap_at=nil, @page_at=nil, @header=nil, @prompt=nil, @key=nil, @use_color=true, @track_eof=true, @terminal=#
#<HighLine::Terminal::IOConsole:0x007fd9bd0ad220 @input=#<IO:<STDIN>>, @output=#<IO:<STDOUT>>>
nil
nil
error: undefined method `first' for nil:NilClass. Use --trace to view backtrace
I'm not really savvy in Ruby, so do please let me know what other info I should provide?
Please, could you issue a puts HighLine::VERSION
just to be sure your environment is set right. Perhaps your fireing different highline versions when switching from your script to irb. Just a guess.
Were already able to run bundle exec rake acceptance
.
I need that final report like this:
=== HighLine Acceptance Tests Report
Date: 2019-02-21 11:32:33 UTC
HighLine::VERSION: 2.0.1
Terminal: HighLine::Terminal::IOConsole
RUBY_DESCRIPTION: ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17]
Readline::VERSION: 7.0
ENV['SHELL']: /bin/bash
ENV['TERM']: xterm-256color
ENV['TERM_PROGRAM']: iTerm.app
Sure
bundle exec bro gzip 259ms Thu Feb 21 15:03:00 2019
5 entries for gzip -- submit your own example with "bro add gzip"
2.0.1
#<HighLine:0x007fd1f80768c8 @input=#<IO:<STDIN>>, @output=#<IO:<STDOUT>>, @multi_indent=true, @indent_size=3, @indent_level=0, @wrap_at=nil, @page_at=nil, @header=nil, @prompt=nil, @key=nil, @use_color=true, @track_eof=true, @terminal=#
#<HighLine::Terminal::IOConsole:0x007fd1f80765d0 @input=#<IO:<STDIN>>, @output=#<IO:<STDOUT>>>
nil
nil
error: undefined method `first' for nil:NilClass. Use --trace to view backtrace
and
=== HighLine Acceptance Tests Report
Date: 2019-02-21 14:05:10 UTC
HighLine::VERSION: 2.0.1
Terminal: HighLine::Terminal::IOConsole
RUBY_DESCRIPTION: ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin18]
Readline::VERSION: 8.0
ENV['SHELL']: /usr/local/bin/fish
ENV['TERM']: screen-256color
ENV['TERM_PROGRAM']: iTerm.app
Im so sorry I couldn't progress on this. Passing here just to let you know that I still care for your issue.
No worries, let me know if you need more traces or debug logs, etc.
def output_cols
return 80 unless @output.tty?
terminal.terminal_size.first
rescue NoMethodError
return 80
end
If terminal @output
is not a tty?
then terminal.terminal_size
should not return nil
.
I could just put a default fallback value for that (the same as I did for when it is not a tty?
).
Could you please check these lines and copy past the results here?
p STDIN.tty? # should be true
p STDIN.terminal_size # should be an array with 2 values (lines and cols size)
@asfaltboy I'm reviewing the issues list.
Could you confirm this issue still exists?
I don't have High Sierra so I'm not able to reproduce it.
I'll be closing this, but feel free to comment or reopen it if it's still happening.
Thanks for reporting.
I tried bumping highline version from 1.6.2 to 2.0.1 in hubsmoke/bro/#75 but this caused me to spend an obscene amount of time trying to replace
HighLine::SystemExtensions.terminal_size
withHighLine.new.output_cols
... It seemsHighLine.new.terminal
in latest version is mutilated on my environment (MacOS Mojave 10.14.3) and terminal is alwaysNil
.The interesting thing is that on 1.6.2 that previous call to
terminal_size
worked just fine...