ubill
Iex Shell: How to delete/overwrite an alias in the shell?
I have asked this question on Slack, no solutions from there, so putting it up here.
The situation is,
Let’s say I’ve typed in the iex shell alias Asdf.Qwer, but actually what I need now is simply Qwer , I have no way to clear Asdf.Qwer because alias Qwer just again gives me Asdf.Qwer . So am I forever stuck with that? Or is there a way to reset/delete aliases
In other words, Qwer is now forever referring to Asdf.Qwer because of my mistype, and there is no way to delete/say that I don’t want this anymore. Or is there?
(P.S. an unrelated question, is the source code of Elixir Forum available as open source somewhere? It’s a great interface and I admire it very much.)
Marked As Solved
bobbypriambodo
Also Liked
bobbypriambodo
Hmm, funny, it seems that you can overwrite alias in some cases and can’t in other cases. I’ve played with this:
iex> alias Asdf.Qwer
Asdf.Qwer
iex> Qwer
Asdf.Qwer
# still not working
iex> alias Qwer
Asdf.Qwer
iex> alias Qwer, as: Qwer
Asdf.Qwer
# this works?
iex> alias Foo, as: Qwer
Foo
iex> Qwer
Foo
# this also works
iex> alias Bar.Qwer
Bar.Qwer
iex> Qwer
Bar.Qwer
# funnily, this seemed to work at first glance (but really doesn't)
iex> alias Elixir.Qwer
Qwer # refers Qwer, yeay!
iex> Qwer
Bar.Qwer # it reverts, the alias doesn't work.
josevalim
This is a bug. Can you please file a bug report?
bobbypriambodo
Is closing and reopening the shell (or via respawn) not a viable solution? (basically it will clear all bound variables and aliases in the shell.)
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








