うちのいぬ Tech Blog

Tech Blog of Uchinoinu/My dog

rails c(bin/rails c) cannot load env vars managed by direnv

Japanese here uchinoinu.hatenablog.jp

Situation

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

  • Manage environment variables by direnv

  • run rails command using Spring

Problem

Adding new environment variables, rails c cannot load any environment variables (maybe rails s too)

How to solve this

Restart Spring(stop any Spring process)

$ bin/spring stop
Spring stopped.

Then, rails c can load env vars.