piotrmurach / tty

Toolkit for developing sleek command line apps.
https://ttytoolkit.org
MIT License
2.5k stars 78 forks source link

TTY is using old version of gem unicorn-display_width #76

Closed yart closed 3 years ago

yart commented 3 years ago

I gave follows when installed gem tty:

NOTE: Gem.gunzip is deprecated; use Gem::Util.gunzip instead. It will be removed on or after 2018-12-01.
Gem.gunzip called from /home/yart/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/unicode-display_width-1.1.3/lib/unicode/display_width/index.rb:5.

Sample of code:

require 'tty'

cursor = TTY::Cursor

cursor.invisible do
  # some code
end

My environment

piotrmurach commented 3 years ago

Hi Artёm 👋

Thanks for trying tty gem out.

I do prefer unicorn-display_width name to unicode-display_width, way cooler!

I must admit the tty gem is horribly out of date. But, all the tty components have been updated so please could you use the master branch for now to generate a CLI app? I will make a new release soon.

Having said that, in your CLI tool you should not depend on tty gem. It is only used to generate a new app but shouldn't be required. Instead, if you wish to use any tty gems please install and require them directly. See the full list of tty components.

So, in your case do:

require "tty-cursor"

cursor = TTY::Cursor

cursor.invisible do
  # some code
end

Hope this helps.

yart commented 3 years ago

Hi Piotr!

Thanks for your advice. I didn't read it before I tried to put the following string to my Gemfile and did 'bundle update':

gem "unicode-display_width", ">= 2.0.0"

So the gems were updated and the trouble was fixed but I think the advice makes sense because my other app hasn't had the same trouble when I used only a part of ‘tty’ at it as you advised.

piotrmurach commented 3 years ago

Good point, I'll look through dependencies to ensure that the latest unicode-display_width is supported. For now, I'd relax the requirement to something like this:

gem "unicode-display_width", ">= 1.6", "< 3.0"

With this change all tty gems should be compatible. That's exactly what I've used in tty-progressbar. There is no difference between 1.7.0 and 2.0.0 of unicode-display_width when it comes to Unicode support. There is an API change that doesn't extend the String class by default.