shahryarjb

shahryarjb

Mnesia has no access to create table in disc macOs dev mode

Hello, I have read many posts about disc problem in the forum, but I have still this problem:

I have no problem to create ram copy

 {:create_table,
  {:aborted, {:bad_type, MishkaAuth.User.Users, :disc_copies, :nonode@nohost}}}}

I did this comment before creating a post:

my config file:

config :mnesia, dir: "/Users/shahryar/Desktop/D-Access/mnesia_db"
# drwxr-xr-x   3 shahryar  staff         96 Mar 22 15:04 mnesia_db

My fields and mnesia name:

  @mnesia_tab __MODULE__

  @mnesia_tab_fields [
    :id,
    :full_name,
    :username,
    :email,
    :mobile,
    :password_hash,
    :unconfirmed_email,
    :unconfirmed_mobile,
    :roles,
    :scopes,
    :devices,
    :status,
    :inserted_at,
    :updated_at
  ]

And the function I create a disc_copies table

def start_mnesia() do
  :mnesia.stop()

  :mnesia.create_schema()
  |> IO.inspect(label: "Mnesia schema start of user ====>")

  :mnesia.start(:app)
  |> IO.inspect(label: "Application start of user ====>")


  case :mnesia.create_table(@mnesia_tab,
          type: :set,
          disc_copies: [Node.self()],
          attributes: @mnesia_tab_fields,
          index: [:username, :email, :mobile],
          record_name: @mnesia_tab,
          storage_properties: [ets: [{:read_concurrency, true}, {:write_concurrency, true}]]
        ) do
    {:atomic, :ok} -> :ok
    {:aborted, {:already_exists, @mnesia_tab}} -> :ok
    any -> {:error, {:create_table, any}}
  end
  |> IO.inspect(label: "Creating table ---->")

  :mnesia.wait_for_tables([@mnesia_tab], :timer.seconds(15))
  |> IO.inspect(label: "Mnesia wait for tables start of user ====>")
end

I am using mac os and dev mode with iex -S mix phx.server

Please help me to fix this issue, 3 or 4 years ago I fixed it, but I can not remember now :frowning:

Thank you in advance

Most Liked

rvirding

rvirding

Creator of Erlang

:wink: :smile: :wink: :smile:
Yes, Mnesia is an old Erlang tool and in Erlang strings are charlists. That’s the way it is.

shahryarjb

shahryarjb

I remove my custom path and it works, but I dont know why i can not set a dir for mnesia

for example if i set a path:

Application.put_env(:mnesia, :dir, "/Users/shahryar/Desktop/D-Access/mnesia_db")

or

:mnesia.stop()
Application.put_env(:mnesia, :dir, "/Users/shahryar/Desktop/D-Access/mnesia_db")

after that call

:mnesia..create_schema([node()])

It returns {:error, {:EXIT, :function_clause}}

I do not know why

Update

use this :rage: :rage: :rage: :rage: :rage: :rage:

Application.put_env(:mnesia, :dir, mnesia_dir |> to_charlist)

Where Next?

Popular in Questions Top

JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
LegitStack
I’m hoping you guys can give me some general advice and perhaps code examples if you’re feeling up to it. I’m very interested in Elixir,...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
gonzofish
I’m currently trying to understand how to join three tables using Ecto. All the examples I’ve seen use 2, so maybe I’m just missing somet...
New
lucidguppy
I have a super simple question about elixir - how would I take a file like this foo bar baz and output a new file that enumerates th...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New

Other popular topics Top

pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: https://hexdocs.pm/ecto/Ecto.Schema.html#module-...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
mgjohns61585
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list....
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New

We're in Beta

About us Mission Statement