nonware
Hello! An Elixir neophyte here. I’d like to debug my code using VS Code. I saw in the ReadMe for ElixirLS you can sink breakpoints for one’s code and step through it, as one might with an IDE (or other language even in VS Code).
The code I am learning with I’ve compiled by running iex -S mix and I am invoking MyModule.my_function(someArg) but the breakpoint i placed in VS Code on some line in my_function is never hit. I do see that there is an open issue where one can’t debug in an iex -S mix session. So that brings me to my question: How do I hit this break point? Is there some setup in VS Code or something to pass to mix to enable debugging so I can hit the breakpoint in VS Code?
Thanks a bunch!
Trending in Questions
Hey guys,
I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly
Do you guys have any suggestions what is the best prac...
New
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
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
I’m trying to set up Emacs with elixir-ls via lsp-mode and credo via Flycheck. This should mostly be preconfigured as Flycheck picks up c...
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
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
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
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
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
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
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixirconf-us
- #elixir-ls
- #ai
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming











Showing Posts 1 to 6- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
mindok
Hi @nonware, this isn’t answering your question directly I know, but I tend to use an
IO.inspect(or friends) either side of a function call as my primary debugging tool. Elixir is a functional language and by and large you put data into a function and get transformed data out with no side effects so I find this style of debugging quite effective for me personally. In addition, code recompile and reload in a running system is generally very quick and just works in Phoenix, so moving a fewIO.inspects around while the system is running is no trouble. I coded a lot of .Net in the past and made heavy use of the Visual Studio debugging tools, which were excellent, but I honestly haven’t found the same need for that style of debugging (yet) in Elixir. In over 2 years I haven’t even taken the time to try and set them up.I’d be keen to hear informed responses though - it’s probably about time I learned about it!
WFransen
I’m personally a huge fan of IEx.pry.
There’s a great article on debugging, not necessarily with VsCode, but maybe this can be helpful. Debugging techniques in Elixir « Plataformatec Blog
Best of luck!
mike_bianco
I’m having similar trouble with getting the vs code debugger working with elixir-ls. Would love to hear how folks are able to get the debugger working with ExUnit tests.
harmon25
I am with @mindok on this one.
In a mutable language where variables can be changed under your nose, breakpoints are more useful in my opinion.
If you have such a big elixir/erlang function that you cannot keep track of the values of variables - and a breakpoint is the best(?) way to verify the value/state is what you expect; I think you may want to consider breaking that function up, so it is easier to comprehend.
Tools like
:observerare also quite useful for real time debugging - as a breakpoint in the IDE does little to assist in understanding the rest of the state of the runtime at that point in time. This is a result of erlangs actor model, and concurrency characteristics - that traditional imperative languages do not use.Also the built in :debugger module that opens a window will struggle in certain environments, like VScode + WSL, as there is not a xdisplay for the window. Not sure if this is what the elixir-ls breakpoint stuff relies on, but if developing in an environment that does not have native GUI capabilities, the functionality might not work.
Am also interested to hear compelling use cases for using breakpoints in the beam, as I might be missing something!
chrisdel101
Did U ever figure this out? I’m looking for breakpoint usage specifically to get away from having to use inspect all the time.
lukaszsamson
Attaching debugger to code running elsewhere (e.g. in terminal
iex -S mixsession) is currently not supported.In order to debug and be able to hit breakpoints you need to run your code with a debugger. In VSCode go to Run And Debug tab ans choose an appropriate launch config. Alternatively you can debug tests from Testing tab or right clicking on an icon next to test definition and selecting Debug Test.