How to get a remote REPL to read from STDIN pipe

This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the bash category.

Last Updated: 2024-04-13

Say you have a REPL on a remote server. You want to run some code there that only exists in a local script and is not checked into git because it contains sensitive information.

How can you run your local script in that remote REPL without needing to copy and paste it into the console and deal with the usual readline weirdness that makes copying and pasting unstable.

The trick is to use a --no-tty option (if available) when working with the remote console.

cat some_script.rb | heroku run console --no-tty