Launchy::CommandNotFoundErrorの解決策

AWS + Rails + letter_openerでLaunchy::CommandNotFoundError

AWS(AmazonLinux)でRuby on Railsのアプリを構築していたのですが、letter_openerというgemでLaunchy::CommandNotFoundErrorというエラーが出ていました。

Launchy::CommandNotFoundError (Unable to find a browser command. If this is unexpected, Please rerun with environment variable LAUNCHY_DEBUG=true or the '-d' commandline option and file a bug at https://github.com/copiousfreetime/launchy/issues/new):

ググってもHerokuやVagrantやletter_opener_webの事例しか出てこずに四苦八苦したのですがエラーメッセージにあるようにブラウザコマンドがないことが原因なので、Headless Chromeをインストールしたら解決しました。AmazonLinuxの場合は以下のコマンドでインストールできます。

$ curl https://intoli.com/install-google-chrome.sh | bash

Launchyの送信するメールを外部ドメインで読みたい場合は config/environments/development.rb でletter_opener_webを使うように設定すると良いでしょう。

  config.action_mailer.default_url_options = { host: "localhost", port: "3000" }
  config.action_mailer.delivery_method = :letter_opener_web