piotrmurach / tty

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

tty is not accepting input when generating a new app using Ruby 2.7.2 via asdf #78

Open konung opened 3 years ago

konung commented 3 years ago

Are you in the right place?

Describe the problem

Hi.

I'm trying out TTY for the first time. Trying to generate a new app and hitting a wall immediately. It just sits there and does nothing. When pressing "return" is just goes to the new line, pressing Ctrl+C exist app.

Steps to reproduce the problem

 teletype new issup 

Actual behaviour

 teletype new issup                                                                                                                                                                                                                                       
Creating gem 'issup'...
rspec is already configured, ignoring --test flag.
Do you want to set up continuous integration for your gem? Supported services:
* CircleCI:       https://circleci.com/
* GitHub Actions: https://github.com/features/actions
* GitLab CI:      https://docs.gitlab.com/ee/ci/
* Travis CI:      https://travis-ci.org/

Future `bundle gem` calls will use your choice. This setting can be changed anytime with `bundle config gem.ci`.
Enter a CI service. github/travis/gitlab/circle/(none):
gitlab
github
none
^C
/Users/konung/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/tty-command-0.9.0/lib/tty/command/process_runner.rb:146:in `join'
/Users/konung/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/tty-command-0.9.0/lib/tty/command/process_runner.rb:146:in `read_streams'
/Users/konung/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/tty-command-0.9.0/lib/tty/command/process_runner.rb:48:in `run!'
/Users/konung/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/tty-command-0.9.0/lib/tty/command.rb:185:in `execute_command'
/Users/konung/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/tty-command-0.9.0/lib/tty/command.rb:104:in `run'
/Users/konung/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/tty-0.10.0/lib/tty/commands/new.rb:126:in `execute'
/Users/konung/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/tty-0.10.0/lib/tty/cli.rb:128:in `new'
/Users/konung/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
/Users/konung/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
/Users/konung/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
/Users/konung/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/thor-0.20.3/lib/thor/base.rb:466:in `start'
/Users/konung/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/tty-0.10.0/exe/teletype:14:in `<top (required)>'
/Users/konung/.asdf/installs/ruby/2.7.2/bin/teletype:23:in `load'
/Users/konung/.asdf/installs/ruby/2.7.2/bin/teletype:23:in `<main>': interrupted

Expected behaviour

It should let me proceed past this point

Describe your environment

I'm using fish-shell in iTerm, but I also tried bash and using osx built-in terminal to the same effect. As well as restarting iTerm and opening new sessions. Nothing seems to work

konung commented 3 years ago

Update

Looks like if I switch to Ruby 2.6.6 tty new app works as expected. But it also didn't ask me about CircleCI/Travis, etc (Huh ? moment?)

Also I noticed that tty is using an old version of tty-command, which is why it could be having trouble with newer version of Ruby? Just an idea.

konung commented 3 years ago

As far as I can tell the culprit is actually bundler? My ruby 2.7.2 had 2.2.6 as the default version of bundler. But my Ruby 2.6.6 (that didn't give me problems) was running 1.7.3 as the default.

piotrmurach commented 3 years ago

Hi Nick 👋

Thanks for giving the tty project a try. I do apologise for the not-so-great experience. This gem requires an update!

Thanks also for this report! It seems to me that tty-comand and this issue in particular is at fault. This will be a priority for me to fix. Though I cannot promise any timelines as I do this in my spare time.

AsifulNobel commented 3 years ago

@piotrmurach Is there any update on this issue? I cloned the master branch of tty today and ran into this issue. I am using ruby 3.0.1 with asdf. If this is not fixed, is there any workaround?

AsifulNobel commented 3 years ago

So after posting the comment, I was trying to debug the issue with VSCode and ran the command a couple of times. Then everything started working again. But the CI configuration prompt no longer appears and I am not sure what fixed the problem. Below is a screenshot of the terminal output -

image

I remember setting the writers array to [stream] after compacting it once and everything started working on subsequent runs.

https://github.com/piotrmurach/tty-command/blob/1340c436e8c111dc9eb94997c5cf818bc8bfd42e/lib/tty/command/process_runner.rb#L90-L93

Nevertheless I am happy with the output I have got and thanks @piotrmurach for creating these gems. 🏆

jedschneider commented 3 years ago

so, I ran into this today, ruby 3.0.1p64 Bundler version 2.2.17 and tty-0.10.0 and tty-command-0.9.0

I ran into a couple of issues where argument forwarding was broken and was not passing arguments through to the Thor executable that actually does the work of assembling the bundle gem arguments from the options. But even once I spiked that and got it calling bundle correctly, I also ran into the ci option issue identified here. Once I hard coded the ci option in the list of arguments passed to bundler I ran into the next problem which was bundler asking about creating a changelog. AFAIK the changelog dialog does not have a cli flag to avoid the prompt, so at this point, I think we're sorta stuck until we can forward stdin arguments as I think folks in this thread have already identified.

One possible solution I can think of is to provide a workflow where you can provide an existing bootstrapped gem and it will instrument it for tty, instead of tty trying to wrap bundler. Basically this stuff here: https://github.com/piotrmurach/tty/blob/master/lib/tty/commands/new.rb#L142-L146.

bundle gem app
teletype bootstrap app

or something