简体   繁体   中英

heroku run rails console hangs when input is provided via STDIN

Using the repo provided by heroku, I could easily get one minimal working rails app .

On my local machine, I use heroku toolbelt to interact with the app:

$ heroku run rails c
Running `rails c` attached to terminal... up, run.7546
putsLoading production environment (Rails 4.0.3)
irb(main):001:0> puts 'hello'
hello
=> nil
irb(main):002:0>

I use <Ctrl-D> to exit, though it doesn't show on the terminal. So far so good.

However, I can not exit the console, if I start it by piping the command to rails c .

$echo 'puts 1' | heroku run rails c
Running `rails c` attached to terminal... up, run.3181
puts 1
Loading production environment (Rails 4.0.3)
irb(main):001:0> puts 1
1
=> nil
irb(main):002:0> exit

Neither <Ctrl-D> nor exit works. It seems it's stuck forever.

In another shell, the relevant output for heroku ps :

=== run: one-off processes
run.3181 (1X): up 2015/02/03 13:46:45 (~ 6m ago): `rails c`

It would be great if someone could shed some light on this behavior.

It seems one bug in heroku command line tool. Ticket is created here .

For now, I think @sadleb 's answer, appending exit to the command string, would be enough for practice.

EDIT:

By now, heroku team has proposed a workaround/solution, mentioned in above github issue:

echo 'puts 1' | heroku run --no-tty rails c

Try $echo 'puts 1; exit' | heroku run rails c $echo 'puts 1; exit' | heroku run rails c

I can't shed any light on why you have to do that though...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM