Code.eval_string() raises warnings when parsing Mix.lock

Skip to first unread message

Thibaut Barrère

Mar 21, 2024, 12:05:40 PMMar 21
to elixir-lang-core

A slightly exotic use-case, but I would like to have your opinion :-)

While doing maintenance work, I often leverage the fact that Mix.lock content is "valid Elixir" to implement useful stuff.

Two examples are: to automatically generate "diff" sections on maintenance PR (see "Changelogs" sections at
- other tooling to verify that unwanted dependencies have not been replaced unwillingly (example at, there is code in addition to French!)

The point I want to bring is that this call (at least on Elixir 1.15):


raises warnings such as:

warning: found quoted keyword "mox" but the quotes are not required. Note that keywords are always atoms, even when quoted. Similar to atoms, keywords made exclusively of ASCII letters, numbers, and underscores and not beginning with a number do not require quotes


This is not a super blocking point at this stage, but I wonder if ensuring that Mix.lock is formatted in a way that does not lead to warning would be a possibility here?

Alternatively, what would be better ways to get the same value (maybe leveraging Mix internals), without having to "migrate" the format?

The tooling I use is here to stay, and worst case I can either ignore the warnings, or "pre-process" the file to remove them, if needed.


-- Thibaut

Wojtek Mach

Mar 21, 2024, 12:14:18 PMMar 21
Please use ElixirForum and such to ask questions as broader community can answer as well as see replies. This ML tends to be focus on feature requests.

On v1.16 you should be able to pass emit_warnings: false. I believe there are equivalents on prior versions, they should be documented in this function:

Thibaut Barrère

Mar 21, 2024, 12:18:46 PMMar 21
to elixir-lang-core
Thanks Wojtek - I was unsure if this would result in a potential change request (on the format of Mix.lock itself), hence my posting here, but well noted!

Thanks for hint as well, that should do!

-- Thibaut

Reply all
Reply to author
0 new messages