michaeljones
How to safely read contents of mix.lock?
I would like to read the contents of the mix.lock file. It seems to be valid Elixir syntax and so I can do a File.read and a Code.eval_string but eval_string is inherently unsafe and the contents of mix.lock should just be a data structure without any side-effecting code that might be dangerous.
Ideally I think I’m looking for equivalent of ast.literal_eval in Python: ast — Abstract syntax trees — Python 3.14.6 documentation But I guess there might also be a official module somewhere that helps with this? I don’t know.
I’m playing around with nushell and trying to write a plugin that generates table data from the mix.lock contents. Just a bit of fun. Not going anywhere really.
Marked As Solved
NobbZ
Take look at credos config loader.
https://github.com/rrrene/credo/blob/master/lib/credo/exs_loader.ex
It’s safe variant basically does load the file and parses it into AST via elixir tooling, but then manually traverses the AST to get the actual value.
I really miss an elixir equivalent of erlangs :file.consult.
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









