うちのいぬ Tech Blog

Tech Blog of Uchinoinu/My dog

direnvで環境変数を管理していて、springへのpathも貼っている場合、環境変数を編集すると、rails cとかで環境変数が読み込めなくなるエラーへの対応

English here

uchinoinu.hatenablog.jp

状況

  • Rails 4.2
  • Ruby 2.3
  • Spring 1.3.5
  • direnv 2.8.1

  • direnvで環境変数を管理している

  • Springを使ってrailsコマンドを動かしている

問題

環境変数を追加したら、rails sは通るけど、rails cでは環境変数を読み込めなくなった(rails sもあやしい)

対応

Springを再起動(stopして全部のSpringプロセスを殺す)

$ bin/spring stop
Spring stopped.

これで、rails cとか打てば、通常に動く。