1

in iex -S mix when I do alias MyApp.Services.DoStuff

I see a response of MyApp.MyApp.Services.DoStuff

Which doesn't seem to let me use my module in the console.

My module is defined in lib/myapp/services/dostuff.ex

defmodule MyApp.Services.DoStuff do ...

Terence Chow
  • 10,755
  • 24
  • 78
  • 141
  • Are you able to call `MyApp.Services.DoStuff.some_function` (for some valid function name)? And what does `DoStuff.some_function` (for the same function name) say after doing the `alias`? – Dogbert Dec 03 '16 at 13:06
  • @Dogbert If I do `MyApp.Services.DoStuff.some_function` before I use alias I get `MyApp.MyApp.Services.DoStuff` is undefined module not available. If I then use alias, I get the same error – Terence Chow Dec 03 '16 at 13:13
  • Just read the part about Elixir alias and it looks like `alias Elixir.MyApp.Services.DoStuff` will allow me to use my functions in that module, but I'm confused why I need to namespace with Elixir when the alias without a namespace seems to think I want to import `MyApp.MyApp.Services.DoStuff`? – Terence Chow Dec 03 '16 at 13:15
  • Do you have anything in `.iex.exs`? Are you running any code before the `alias` in `iex`? Can you try replicating this in a brand new mix project? It's a little hard to debug like this without having a reproducible case locally. – Dogbert Dec 03 '16 at 15:50
  • @Dogbert ahhhh ok looks like I accidentally added alias MyApp.MyApp in my `.iex.exs` Didn't even realize it! Thanks! – Terence Chow Dec 03 '16 at 19:15

1 Answers1

1

As per the comments Dogbert led me to realize that I had accidentally aliased MyApp.MyApp in my .iex.exs file. Must have been due to a lot of copy pasting...

Terence Chow
  • 10,755
  • 24
  • 78
  • 141