So I'm getting {aborted,{bad_type,link,disc_copies, '[email protected]'}}
(it is returned by my init_db/0
function):
-record(link, {hash, original, timestamp}).
init_db() ->
application:set_env(mnesia, dir, "/tmp/mnesia_db"),
mnesia:create_schema([node()]),
mnesia:start(),
mnesia:create_table( link,[
{index,[timestamp]},
{attributes, record_info(fields, link)},
{disc_copies, [node()]}]).
Without {disc_copies, [node()]}
table is properly created.
Verify write permissions on the parent directory of the mnesia dir you're specifying via
application:set_env/3
. If the mnesia dir parent directory doesn't allow you to write, you'll get this error. (Another way to get this error is to forget to set mnesia dir entirely, but yourset_env
call is clearly doing that.)Update: looking more carefully at your reported error, I see the node mentioned in the error is not in a list:
This might mean that the code you show in your question doesn't match what's really running. Specifically, if you call
mnesia:create_table/2
passing a node instead of a list of nodes in thedisc_copies
tuple, as shown below, you'll get the same exact error: