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’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
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
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
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
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
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
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
Aludel - LLM Evaluation Workbench
Aludel is an embeddable Phoenix LiveView dashboard for evaluating and comparing LLM prompts across mult...
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
- #ai
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










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?