Gigalixir lets us start a remote shell, similar to iex --remsh. The command is:
gigalixir ps:remote_console -a my-app
Does anyone know if there is a way to make this shell use my project’s .iex.exs. I want this because my .iex.exs contains lots of nice aliases. I get very tired of typing alias MyApp.SomeContext.SomeModule.
This is a perfect workaround for my use case but I cannot mark it “solution” unless we are sure there is no way to use the project iex.exs in gigalixir remote_console.
It seems it’s a matter of where you start your release from and whether that
directory contains the .iex.exs file and so you could change your :releases
Mix configuration to copy the file into appropriate location.
I did notice one thing that while executing code or setting up aliases in the .iex.exs file work, autocomplete of these aliases does not so it’s seems
it’s not fully supported.
Sounds like one could create a release step bundling a local .iex.exs like config/releases.exs and editing remote_console, so it automatically loads from there.
OK so I moved from doing Mix releases to doing Elixir releases with clustering and I discovered that the .iex.exs simply is nowhere on the deployed instance:
connect to instance:
gigalixir ps:remote_console
search for .iex.exs:
System.cmd("find", ["/", "-name", ".iex.exs"])
returns:
{"", 0}
so I guess the release doesn’t include the .iex.exs. I am starting to understand more now.
I’ve said it before and I’ll say it again. This forum is sooo good. The advice people give is such high-quality. It’s like living next to the Mage’s Guild.
Basically, what’s happening is the Distillery packs up a bunch of stuff into a tarball, but it normally doesn’t include the .iex.exs file so when you remote console into production, the .iex.exs file isn’t there. Elixir releases, which is different from Distillery, will just pick up anything in the rel/overlays directory and include it in the tarball, but I don’t think distillery does that. You have to actually modify your rel/config.exs file and tell it which files you want to include with something like this (untested)
set overlays: [
{:copy, ".iex.exs", ".iex.exs"}
]
Once everything is configured correctly, just commit to git and re-deploy. Gigalixir automatically recreates the release for you.