Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined method auto_spin #48

Closed
johncadengo opened this issue Dec 10, 2021 · 2 comments
Closed

Undefined method auto_spin #48

johncadengo opened this issue Dec 10, 2021 · 2 comments
Labels

Comments

@johncadengo
Copy link

This is the error I get:

undefined method `auto_spin' for #<TTY::Spinner:0x00000001478491d8 @message="[:spinner] Loading ...", @format=:pulse_2, @output=#<IO:<STDERR>>, @hide_cursor=false, @frames=["▁", "▃", "▅", "▆", "▇", "█", "▇", "▆", "▅", "▃"], @clear=false, @success_mark="✔", @error_mark="✖", @interval=15, @callbacks={}, @length=10, @current=0, @done=false, @state=:stopped> (NoMethodError)

Here is my code:

  spinner = TTY::Spinner.new("[:spinner] Loading ...", format: :pulse_2)
  spinner.auto_spin
  
  sleep(5)

  spinner.stop

What am I doing wrong?

@johncadengo
Copy link
Author

I see what happened. I used gem 'tty' in my Gemfile and this is what version it installed by default, using Bundler 2:

      tty (0.5.0)
      equatable (~> 0.5.0)
      pastel (~> 0.6.0)
      tty-color (~> 0.3.0)
      tty-command (~> 0.1.0)
      tty-cursor (~> 0.3.0)
      tty-pager (~> 0.4.0)
      tty-platform (~> 0.1.0)
      tty-progressbar (~> 0.9.0)
      tty-prompt (~> 0.6.0)
      tty-screen (~> 0.5.0)
      tty-spinner (~> 0.2.0)
      tty-table (~> 0.5.0)
      tty-which (~> 0.1.0)

I think this is pretty odd default behavior and it wasn't clear in the documentation not to include gem 'tty' in my Gemfile until I read through the issues: piotrmurach/tty#50:

Additionally, the tty is not a gem you should depend on. It is a metagem used only to provide a way to scaffold a terminal application. In other words, it shouldn't be used in Gemfile. I may add some documentation in line with this.

Anyhow, my feedback is not to make use of a "metagem" because I haven't encountered any other gem that functions like this before.

@piotrmurach
Copy link
Owner

Hi John,

Thanks for using tty-spinner and providing feedback on tty gem. This is very useful.

The tty gem is out of date. I'm currently rewriting it so that it makes tty components into suggested dependencies without installing almost any of them(some core gems will be required). In other words, to use for example tty-spinner you will need to comment it out in your gemspec and install it to use it which will guarantee the latest version.

Anyhow, my feedback is not to make use of a "metagem" because I haven't encountered any other gem that functions like this before.

The tty is a generator for scaffolding new CLI apps and is not to be required as a dependency. I'll make sure that's clear and loud in the readme and the future implementation. As for any other gem, the bundler is a good example here, it can be used to scaffold a new gem but you don't depend on it and don't need to use it to develop your gem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants