AndyL
I’d like to add some custom helper functions to iex. I use .iex.exs and can define a module there with my custom functions. But I can’t figure out how to auto-import the module into my iex environment. I’ve tried hacking the iex bash script (at /usr/local/bin/iex), browsed thru the iex source - no luck. Is there a way to extend IEx.Helpers, or auto-import my .iex.exs module?
Trending in Questions
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
Hello,
I’m trying to build a basic Phoenix web-app, and I’d like to use Tailwind.
However, when I launch mix phx.server, I get an error...
New
Hi everyone,
I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding.
I sta...
New
I’m working on a small exercise involving update_in/3, and I came up with this solution:
data = %{
name: "Periodic Table",
category:...
New
I’ve got trouble wrapping my head around the order in which functions are called in this snippet (from Phoenix’s authentication):
toke...
New
Is there any way to avoid the Hologram compiler running when using iex? It seems like the front-end code could potentially be disregarded...
New
** (ArgumentError) expected :max_attempts to be a positive integer, got: {:@, [line: 10, column: 19], [{:max_attempts, [line: 10, column:...
New
Other Trending Topics
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
A little off-topic, but I feel like people here have a good head on their shoulders.
I used to be quite good at making software. Was luc...
New
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ai
- #ecto-query
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #metaprogramming
- #hex










Showing Posts 20 to 11- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
axelson
I knew that aliasing would work but I swear I tried an
import_file_if_available ".iex.exs"and that it failed to actually import a module defined in that.iexs.exsbut indeed it does work great! Thank you!Now if I update my
iandsaliases to:I can type
rrinstead ofrecompilezachallaun
Looking at what
import_file_if_availabledoes, it’s just a macro that reads the file, parses it withCode.string_to_quotedand then spits it out. So I think it should make any aliases/imports available unless you’ve established a new scope. So just to confirm, this definitely doesn’t work when running withiex --dot-iex ~/.iex.exs?Edit: I was just able to try this out and it does seem to be working for me, which is good news! So there must be something else going on, I think:
axelson
This has been a great development! However I’m still struggling with one specific aspect.
If a given project defines it’s own
.iex.exsthat imports a module, is there a way that I can also have a~/.iex.exsthat imports a module? So far I haven’t been able to get that to work without both.iex.exsscripts from having knowledge of each other.Things I’ve tried:
iex --dot-iex ~/.iex.exsto import my own.iex.exs, but then I don’t have a way to load the project-specific.iex.exsCode.eval_file(".iex.exs")then any imports it defines are not availableimport_file_if_available(".iex.exs")then any imports it defines is not availableThe only workaround I have so far is for my
~/.iex.exsto have knowledge of the name of all modules that any of the project-specific.iex.exswants to import and import them all if they exist.josevalim
In Elixir v1.14+ you will be able to import the module as you define it in .iex.exs files, as we now evaluate it line by line: Evaluate --dot-iex line by line · elixir-lang/elixir@395b053 · GitHub
axelson
Ah, ok. I’ll just define the helper somewhere else then.
Qqwy
Unfortunately, no, because it is not possible to import a module in the same file as in which it was defined: you will get above compile error scenario.
axelson
Is there an easy way to define an IEx helper now? I’d prefer to keep the helper definition inside
.iex.exsif possible.chazsconi
That works
Thanks @andy !
AndyL
You need to start iex with the
-paoption to append your home dir to the iex search path. Tryiex -pa ~/Also FYI you can use
import_if_available- prevents the error message if the module is not found.chazsconi
Doesn’t work for me unfortunately.
I have the
Elixir.IEXHelper.beamfile in my home folder and in.iex.exI haveimport IEXHelperI get
** (CompileError) /Users/chazsconi/.iex.exs:1: module IEXHelper is not loaded and could not be foundAny suggestions for how to fix this?