ityonemo

ityonemo

.iex.exs for releases?

Is there a way to make an equivalent for .iex.exs for releases, where a handful of modules are aliased or imported that are useful for the operator in the shell in deployment, or should we just ship .iex.exs to the home directory of the deployment?

Most Liked

LostKobrakai

LostKobrakai

I’d tend to argue against having something like .iex.exs loaded automatically in production. The remote console is quite resistant to errors and not accidentally blowing up production, but even just crashing on startup of the console and potentially blocking you from accessing the the console is something I’d try to avoid greatly. I’d rather have a function like MyApp.Ops.load_my_stuff, which does the same, but needs to be called once manually.

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

Yeah I have a help.ex module in my projects inside of which I have defmodule Help and a __using__ macro so that when I remote console in I can just use Help and get all the things I want.

On the other hand though, if the .iex.exs file really does cause issues you could always remote console into the server / container and delete it before remote consoling into the actual BEAM instance.

ityonemo

ityonemo

OMG sorry to necro this but a use Help is brilliant. Mostly what i want in my remote iex is imports and aliases anyways, and it’s a burden to remember each time… but “use Help” is perfect, because it’s easy to remember and only 9 keystrokes.

seva

seva

Hi Krut,

You can define everything in your help.ex, e.g.:

defmodule Help do
  defmacro __using__ (_opts) do
    quote do

      import Ecto.Query, warn: false
      # ...etc
      
    end
  end
end

and then in your .iex.ex simply add one line:

use Help

that way you only need to define all the imports/aliases in one file.

Where Next?

Popular in Questions Top

Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
dotdotdotPaul
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
tduccuong
Hi, is there any work on GUI with Elixir, that is similar to Electron/Javascript? My idea is to bundle Phoenix and BEAM into a single se...
New
quazar
How to set Jason to encode all fields in ecto schema, I don’t care about security and implementing only is taking long list of attributes...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
johnnyicon
Hi all, I've just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I'm trying to use Postg...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New

Other popular topics Top

srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
Tee
can someone please explain to me how Enum.reduce works with maps
New
Jim
As a follow up to my earlier question: I have the code compiling and running but not getting a successful login from the rest server. ...
New
lk-geimfari
What is most correct way to open, read and parse JSON file with poison? For example if we have example.json file in root of some projec...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lis...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
josevalim
Hi everyone, One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New

We're in Beta

About us Mission Statement