rails credentials:editでNo $EDITOR to open file in. Assign one like this:と怒られる

$ rails credentials:edit
No $EDITOR to open file in. Assign one like this:

EDITOR="mate --wait" bin/rails credentials:edit

For editors that fork and exit immediately, it's important to pass a wait flag,
otherwise the credentials will be saved immediately with no chance to edit.

EDITORが未指定の場合は編集することができないとのこと

解決策

エディタを指定して実行

$ EDITOR="vi" bin/rails credentials:edit

EDITORを環境変数に設定しておく

環境変数に設定しておけば次回以降は rails credentials:edit だけで編集可能です。

echo 'export EDITOR="vi"' >> ~/.bash_profile