Thank you for reporting this! I had no intention of breaking things but releasing this version was a rather large task. I will fix this and release new update shortly. There is definitely great lesson here in managing namespaces.
tty-file breaks tty-which
ruby: 2.4.0p0 (2016-12-24 revision 57164) [x86_64-linux] tty: 0.6.0 tty-which: 0.2.1 OS: Linux (Arch)
With 0.5.0, I could use
TTY::Which by requiring
ruby require 'tty' TTY::Which.which 'ruby' # => "/usr/bin/ruby"
That no longer works in 0.6.0. It appears that unqualified references to
TTY::Which are now being resolved to
TTY::File rather than
I can work around this by requiring
tty-which directly, but this was an unexpected (breaking) change, and I can't see any mention of it in the changelog.
(This might affect other
tty- modules. Some of them have qualified
::File references, some unqualified, and some (e.g.
tty-color) have a mixture of the two.)
ruby gem 'tty', '= 0.5.0' require 'tty' puts TTY::Which.which('ruby')
$ ruby test-0.5.0.rb /usr/bin/ruby
ruby gem 'tty', '= 0.6.0' require 'tty' puts TTY::Which.which('ruby')
$ ruby test-0.6.0.rb ~/.gem/ruby/2.4.0/gems/tty-which-0.2.1/lib/tty/which.rb:157:in `file_with_path?': undefined method `expand_path' for TTY::File:Module (NoMethodError) from ~/.gem/ruby/2.4.0/gems/tty-which-0.2.1/lib/tty/which.rb:23:in `which' from test-0.6.0.rb:3:in `<main>' </main>
4条回答 默认 最新
- 点赞 评论 复制链接分享
The following libs have been fixed and released with new patch levels:
- tty-which (v0.2.2)
- tty-editor (v0.1.2)
- tty-command (v0.3.2)
- tty-color (v0.4.2)
- tty-prompt (v0.10.1)
Given that I only updated patch levels, you should be able to use tty
v0.6.0. Please remove any tty components and then bundle to ensure the latest gems are installed. I've tested and all is fine for me but let me know if the issue is fixed for you.点赞 评论 复制链接分享
- weixin_39870155 2020-12-08 18:40
I upgraded with:
And the components have been updated, and
require 'tty'works as expected. :thumbsup:
Please remove any tty components and then bundle to ensure the latest gems are installed.
I didn't do this, since my affected scripts aren't packaged as gems, but it looks like I should have since they ended up generating the following warning on each run:
WARN: Unresolved specs during Gem::Specification.reset: tty-color (~> 0.4.0) tty-command (~> 0.3.0) tty-editor (~> 0.1.0) tty-prompt (~> 0.10.0) tty-which (~> 0.2.0) WARN: Clearing out unresolved specs. Please report a bug if this causes problems.
But that appears to be an issue with RubyGems. In my case,
gem cleanupdidn't work, but uninstalling and reinstalling the gems one by one has solved it:
$ gem uninstall \ tty-color \ tty-cursor \ pastel \ tty-command \ tty-prompt \ tty-which \ tty-editor \ tty-file \ tty-screen \ tty-pager \ tty-platform \ tty-progressbar \ tty-spinner \ tty-table \ tty $ gem install tty点赞 评论 复制链接分享
Glad it worked! From my experience maintaining scripts and such, using bundler is rather good idea, otherwise you may open yourself to dependency hell and make it hard to maintain things. Bundler is not only good for gem development but any Ruby development unless of course you fancy vendoring dependencies with your script.点赞 评论 复制链接分享