Fix non-tty run issue