Coder Social home page Coder Social logo

Comments (3)

pcewing avatar pcewing commented on July 27, 2024

I ran into this as well and I believe it's actually a limitation with Mix.Config.read!/1.

In distillery, that function is used to read the base configuration:
https://github.com/bitwalker/distillery/blob/master/lib/mix/lib/releases/assembler.ex#L558

Then it's merged with the release configuration and written:
https://github.com/bitwalker/distillery/blob/master/lib/mix/lib/releases/assembler.ex#L537

Observations

Create a new project and add a key to the config whose value is an anonymous function:

mix new potato && cd potato
echo "config :potato, my_var: fn -> :ok end" >> config/config.exs

Start an iex session, read the config, and notice the output:

iex> config = Mix.Config.read!("config/config.exs")
[potato: [my_var: #Function<12.3456789/0 in :erl_eval.expr/5>]]

Correct me if I'm wrong, but that function will only exist in the current BEAM instance. We can't serialize/write it and expect it to be valid during a subsequent execution of the program when we read it; it will be redefined at run time in the new BEAM instance.

Edit: Removing the last observation as I misunderstood the purpose of Mix.Config.persist/1.

from exrm.

bitwalker avatar bitwalker commented on July 27, 2024

@pcewing It's not actually a problem with Mix.Config.read!/1, as it is supposed to return the captured function. The issue is that we need to write a function in capture syntax to the sys.config file, so that when it is evaluated by the VM, we get a valid capture back. What happens now is we serialize the capture, which of course is invalid. It's something I have some ideas on how to tackle, but I'll be doing so in distillery rather than exrm.

from exrm.

szabolcsmaj avatar szabolcsmaj commented on July 27, 2024

Thank you @bitwalker! I'll close this since directions are clear --> Switch to distillery

from exrm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.