Albert Netymk
Albert Netymk

Reputation: 1112

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.

Upvotes: 2

Views: 1611

Answers (2)

Albert Netymk
Albert Netymk

Reputation: 1112

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

Upvotes: 2

sadleb
sadleb

Reputation: 71

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

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

Upvotes: 1

Related Questions