Code.ensure_loaded? in .iex.exs
问题 I have an elixir console configuration stored in .iex.exs : if Code.ensure_loaded?(MyApp.Repo) do alias MyApp.Repo end I want to have an ability to run both iex and iex -S mix . I'll have exception if I remove condition on iex . But this conditions doesn't work well! Even on iex -S mix I have (module Repo is not available) error if I'm trying to invoke Repo.get(...) . So, my questions are: Why Code.ensure_loaded? doesn't work here? How can I fix that? 回答1: This is a matter of scoping. Inside