phewitt
I want to know how to suppress errors in elixir. Ideally a few ways. Fixing them is not an option. We are slowly fixing them.
I’m currently working in a 7 year old umbrella project with many thousands of warnings, thousands of files. I’ve tried both our current elixir 1.15.6-otp-26 and elixir 1.16.0-otp-26. Which the newer version does have nicer looking errors, but is still not what i’m looking for. I’m wanting to optionally suppress the warnings when running tests or trying to identify compile errors locally. Ideally with a flag or shell var so that I can keep it enabled for ElixirLS.
The main motivation behind this is that the REAL errors get drowned in the sea of warnings. I literally have to use the search feature within my terminal to try and find the error. However, even this is terrible because a lot of the warnings include err or error which makes searching difficult.
I feel like in previous versions (i think ~1.14) of elixir the errors would short circuit compilation which at least left the error at the bottom of the output instead of hidden in the middle.
Given this context the best solution I can think of is leveraging compiler flags to minimize or suppress the warnings explicitly when running tests / iex locally. I’ve found a few things that seem like they may help, but I don’t know how to actually enable them / pass them to the erlang compiler.
Things i’ve sort of found, but have not figured out how to use correctly. A couple things i’ve looked at…
-
erlang compiler options,
report_warnings, things likenowarn_unused_vars- if this is the right thing. how can I actually leverage it in elixir. I’ve looked at
ERL_COMPILER_OPTIONS, but can’t seem to get it do do anything.
- if this is the right thing. how can I actually leverage it in elixir. I’ve looked at
-
@compile :nowarn_unused_varsattribute in a module that generates warnings.- This seemed to have no impact…
-
Mix compile options,
--no-all-warnings. I don’t think this is even what i’m looking for but I tried it. or any compile option that might help… -
My coworker literally has a script to grep through the output to help filter down to the errors. I would hate for this to be our only solution…
External links that are related.
What’s blown my mind the most about this is that I feel nearly alone looking at a solution to this. I feel configuring the output of a compiler is a pretty important thing.
Anyhow, hope someone can help! Until then i’ll continue my trash workflow of swimming through warnings.
Thank You!
Trending in Questions
Other Trending Topics
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
- #elixirconf-eu
- #metaprogramming
- #hex










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
TwistingTwists
+1 . Me facing same stuff.
LostKobrakai
It wasn’t a short circuit, but afaik some changes in ordering of IO. But indeed that changed at some point.
There’s explicitly no way to do that afaik. It’s not a nobody is interested in this, but iirc an active choice made by the core team to not have a setting for that.
sodapopcan
Out of curiosity, what are the warnings you are getting? I just ask as they could be easier to fix than you think, even on a huge project, using Sourceror.
phewitt
I hope that’s not the case. I understand discouraging it, but why explicitly restrict it? What’s the benefit? Erlang seems to have the option to do it! I wonder if anyone has some forked elixir that I could just use locally. I wouldn’t know where to begin to patching it myself.
phewitt
I appreciate the reply, but my goal is to avoid this sentiment and style of answer. I’m aware that everyone believes “fixing” the warnings is the correct way, and in a vacuum I agree. I’m also aware there are many ways to scan/update the source programatically. However, This is a higher risk operation that is less than ideal for our large prod codebase. Making huge sweeping changes across the entire codebase (even if trivial) is not something we want to do. In the log run we are working and chipping them away.
I do not need help understanding the fix for any particular warning type… they all make sense. They are not an explicit PROBLEM for us in our system. And some are even expected… There are many types, and it would take me some time to actually figure out comprehensively all of them but to list a few just for you…
module X is not available or is yet to be definedvariable "X" is unused. there is a variable with the same name in the context, use the pin operator (^) to match on it or prefix this variable with underscore if it is not meant to be usedX is deprecated. Use Y insteaddef my_fake_func/1 has multiple clauses and also declares default valuesunused alias Channelmodule attribute @Y was set but never usedundefined module attribute @Ymissing parentheses for expression following "do:" keyword. Parentheses are required to solve ambiguity inside keywords.This is just a sample what I see scanning with my eyes and not comprehensive. There are literally thousands of warnings.
All responses around this idea seem to end up with the same answer. Something along the lines of “just fix the warning” or “the warnings are telling you something is likely wrong with your code”. I hear that and disagree that it’s ALWAYS the case. So, at least here, please respond with direct answers within the scope of my question regardless of how you feel about it. This is why I explicitly said “Fixing them is not an option”.
sodapopcan
Yep, that’s why I said could and was very careful not to use the word “just” (I know we all love when people start a sentence with “Can’t ya just…”). Yes, some of these would be very tough to fix programmatically so it’s not much help to you here. But there are certain classes of warnings that are easy and safe to programmatically fix which is why I asked.
I’m not sure why there is no option to disable warnings. My guess is that it is generally a dangerous thing to do. Warnings give us important feedback during development. If you blanket turned-off warnings then you’ll stop getting new ones as you dev. I could see this bringing up a whole new slew of complaints. I could see turning off everything except for deprecation warnings being useful but ya, I’m also pretty sure there is no way to do this. Again, this is a guess, I’m not on the core team nor do I contribute to the language.
LostKobrakai
You’d likely need to take this up with the core team if you want to change that.
phewitt
i’ll look into it. Thx. I wonder if we could simply have warnings in stdout and errors in stderr. and then I could easily filter them
phewitt
I can’t post on that group. what’s the normal avenue to bring it to discussion with core team? I’de be interested in if they even think it’s hard. if it’s not hard i’ll happily fork elixir and use that locally…
LostKobrakai
The group is the place for elixir development discussions. I’ve posted there before without issues. Here might be seen by people as well. Github issue might be ok given the outlines issues you have as well, not sure about that one though.