Mnesia can't create disc copy

I’m running into problem with mnesia table creation. When I’ve called :mnesia.create_table/2 with option disc_only_copies: [Node.self()] I’ve got bad_type error. So I’ve tried :mnesia.change_table_copy_type/3. With bigger success. Now I’m getting {:aborted, {:has_no_disc, :nonode@nohost}} error.

I didn’t specify any host name.
Platform: Mac OS X, M2 CPU
Erlang: 26.0.2
Elixir: 1.15.5

Code snippet:

alias :mnesia, as: Mnesia

    type: :set,
#    disc_only_copies: [Node.self()],
    record_name: Pulse,
    attributes: @record_fields

Mnesia.change_table_copy_type(Pulse, Node.self(), :disc_copies)

Line commented out was used when I was creating table with disc persistence.

1 Like

Is the directory where you’re running mnesia writable?

You may also want to try running with the environment variable ERL_FLAGS="-mnesia debug trace" set. That way mnesia will give you information about what it’s doing. (-mnesia debug verbose will be less noisy)


I’ve had this in my config. Which caused the bug. Right after I’ve removed mnesia config it just works. I’ve forgotten about it when I was testing elixir libraries interacting with mnesia.

config :mnesia,
  dir: ".mnesia/#{Mix.env()}/#{node()}"
1 Like