Skip to content

rebar3_auto plugin broken due to purge/reload strategy in rebar3_agent #2958

@rvangraan

Description

@rvangraan

I recently added rebar3_auto to our complex project to help recompiling and reloading modules after saving.

However, rebar3_auto breaks as soon as you save the first file and we get errors such as this:

2025-06-17 11:15:29.720+02:00 ERR   <0.4437.0>: CRASH REPORT:   crasher:
    initial call: rebar3_auto:'-do/1-fun-0-'/0
    pid: <0.4437.0>
    registered_name: []
    exception error: undefined function rebar3_auto:auto/1
    ancestors: [<0.9.0>]
    message_queue_len: 1
    messages: [{<0.4441.0>,
                   {fs,file_event},
                    [inodemetamod,modified]}}]
    links: [<0.4463.0>,<0.4493.0>,<0.4505.0>,<0.4518.0>,<0.4531.0>,
                  <0.4537.0>,<0.4543.0>,<0.4546.0>,<0.4547.0>,<0.4549.0>,
                  <0.4544.0>,<0.4540.0>,<0.4541.0>,<0.4538.0>,<0.4534.0>,
                  <0.4535.0>,<0.4532.0>,<0.4525.0>,<0.4528.0>,<0.4529.0>,
                  <0.4526.0>,<0.4521.0>,<0.4522.0>,<0.4519.0>,<0.4511.0>,
                  <0.4514.0>,<0.4515.0>,<0.4512.0>,<0.4508.0>,<0.4509.0>,
                  <0.4506.0>,<0.4499.0>,<0.4502.0>,<0.4503.0>,<0.4500.0>,
                  <0.4496.0>,<0.4497.0>,<0.4494.0>,<0.4477.0>,<0.4484.0>,
                  <0.4488.0>,<0.4489.0>,<0.4485.0>,<0.4481.0>,<0.4482.0>,
                  <0.4478.0>,<0.4469.0>,<0.4472.0>,<0.4474.0>,<0.4470.0>,
                  <0.4466.0>,<0.4467.0>,<0.4464.0>,<0.4451.0>,<0.4457.0>,
                  <0.4460.0>,<0.4461.0>,<0.4458.0>,<0.4454.0>,<0.4455.0>,
                  <0.4452.0>,<0.4445.0>,<0.4448.0>,<0.4449.0>,<0.4446.0>,
                  <0.4442.0>,<0.4443.0>,<0.4438.0>]
    dictionary: []
    trap_exit: false
    status: running
    heap_size: 1439468
    stack_size: 28
    reductions: 60308
  neighbours:

I've narrowed the problem down to this code in rebar3_agent:

https://github.com/erlang/rebar3/blob/main/apps/rebar/src/rebar_agent.erl#L148

and specifically:

https://github.com/erlang/rebar3/blob/main/apps/rebar/src/rebar_agent.erl#L316-L319

The behaviour I see is that rebar3_auto asks for a full compile here:

https://github.com/vans163/rebar3_auto/blob/master/src/rebar3_auto.erl#L118

and that then triggers the rebar3 compile. The issue is that the refresh evicts all the code from the VM, including the rebar3_auto module.

I'm not sure that this is desired behaviour. At the very least it should have been selective and only purged modules that have actually changed. It would be much better to separate the compile and reload functionality in two different APIs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions