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 . import xyz
xyz.do_something()
I did a bit of google and this is what I found
$ iex
Code.load_file(“some_file.exs”)
moduleFromSomeFile.doSomething(1)
I was wondering if this is the “right” way to import a module in to iex and just inspecting/playing around with functions.
Thank you
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
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
Hello folks!
So at work, we are seeing some situations where we have to define some “fixed” strings that are used across the codebase in...
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 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
OvermindDL1
If the compiled module is on the binary path for the BEAM then you can just do
import Xyxto import everything from it. Or call it straight withXyz.blah(42).mixsets up all those paths for you automatically if it is part of a project so with a mix project you can just doiex -S mixto get everything linked properly.elderbas
If I’m just dinkin around in a directory, outside of a mix project, and I have a module named “SomeModule.exs” in the working directory and I’m in iex, I do
c "SomeModule.exs", and I’ll have the module available to play with.bgargi
Hey there!
You could simply use- “import abc” (Given that you are in the directory where the module is defined)
and then happily use the functions defined in abc ,and hence without having to do abc.fun1() simply do fun1().
m31271n
import_file/1c/1/c/2/r/1Above are what you need. Enjoy!
robchristian
Wow, not a single one of of these worked for me. Many show the module compile, but then the functions I expect are undefined. Could somebody show me a complete example, of how to run
Jason.encode!(%{ "a" => 1 }), in the Elixir REPL, from inside a mix project?hauleth
axelson
Generally in Elixir you will not be importing modules from outside your project, so you will not need the techniques listed in this post. Instead you will generally declare dependencies (by adding to the list of
depsin yourmix.exsfile). Then (as @hauleth showed) you can runiex -S mixto start aniexsession inside the project, which will have all the modules from all your dependencies loaded (also if you’re using phoenix you may be interested in runningiex -S mix phx.startto have an iex shell in the same beam instance as your phoenix application).Here’s a page from the official tutorial with some more info: https://elixir-lang.org/getting-started/mix-otp/introduction-to-mix.html
fargozhu
what if you need to debug in a docker prod container where you don’t have the mix* files and you need to load HTTPoison to understand a catchy issue that doesn’t happen in your test env?
axelson
Yeah, that doesn’t sound like a general case
mrjbj
I have a fixture under test/support/fixtures that isn’t working. I was hoping to load that module into iex and debug it interactively but i get “module not loaded and could not be found”. Is there a way to config for this scenario? Thanks.