Hi,
I’ve been using GenStage for a few days without any problems, and all of a sudden, this error starts appearing to me:
== Compilation error in file lib/c.ex ==
** (CompileError) lib/c.ex:2: module GenStage is not loaded and could not be found
(elixir) expanding macro: Kernel.use/1
lib/c.ex:2: C (module)
I’ve been trying this with a few new clean projects, using mix new. I tried wiping out _build, but nothing works. I’ve also tested this in a couple of machines. This just doesn’t make any sense…
The C module (GenStage docs page code) contains the following code:
defmodule C do
use GenStage
def start_link(_opts) do
GenStage.start_link(C, :ok)
end
def init(:ok) do
{:consumer, :the_state_does_not_matter}
end
def handle_events(events, _from, state) do
# Wait for a second.
Process.sleep(1000)
# Inspect the events.
IO.inspect(events)
# We are a consumer, so we would never emit items.
{:noreply, [], state}
end
end