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’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
apply_graft/2 doesn’t rewrite an add_many sub-workflow’s deps on an add step. Grafted jobs cancel with “upstream job was deleted”
Version...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
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
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










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.