erix

erix

Adapter Ecto.Adapters.Mariaex was not compiled

I am new to Elixir, so to learn I’m converting an existing NodeJS project into an Elixir one.

I intend to use plain Elixir (no frameworks), Poison (for JSON I/O), MySQL (database).

My mix dependencies:

[
  {:ecto_sql, "~> 3.2"},
  {:poison, "~> 5.0"},
  {:myxql, "~> 0.6.0"}
]

I followed instructions regarding PostgreSQL on StackOverflow and entered command mix deps.clean --all and then mix do deps.get, compile which results in:

** (ArgumentError) adapter Ecto.Adapters.Mariaex was not compiled, ensure it is correct and it is included as a project dependency
    (ecto 3.11.1) lib/ecto/repo/supervisor.ex:61: Ecto.Repo.Supervisor.compile_config/2
    lib/mysql.ex:2: (module)

I tried adding Mariaex to the dependencies:

[
  {:ecto_sql, "~> 3.2"},
  {:poison, "~> 5.0"},
  {:myxql, "~> 0.6.0"},
  {:mariaex, ">= 0.0.0"}
]

and the result was:

Because "mariaex >= 0.9.0-rc.0" depends on "decimal ~> 1.2" and "mariaex < 0.9.0-rc.0" depends on "decimal ~> 1.0", "mariaex" requires "decimal ~> 1.0".
And because "poison >= 5.0.0" depends on "decimal ~> 2.0", "poison >= 5.0.0" is incompatible with "mariaex".
And because "your app" depends on "mariaex >= 0.0.0", "poison >= 5.0.0" is forbidden.
So, because "your app" depends on "poison ~> 5.0", version solving failed.
** (Mix) Hex dependency resolution failed

I tried removing versions in dependencies:

[
  {:ecto_sql, ">= 0.0.0"},
  {:poison, ">= 0.0.0"},
  {:myxql, ">= 0.0.0"},
  {:mariaex, ">= 0.0.0"}
]

and got:

Because "mariaex >= 0.9.0-rc.0" depends on "decimal ~> 1.2" and "mariaex < 0.9.0-rc.0" depends on "decimal ~> 1.0", "mariaex" requires "decimal ~> 1.0".
And because "the lock" specifies "decimal 2.1.1", "the lock" is incompatible with "mariaex".
And because "your app" depends on "the lock", no version of "mariaex" is allowed.
So, because "your app" depends on "mariaex >= 0.0.0", version solving failed.
** (Mix) Hex dependency resolution failed

Is a connection between Ecto and MySQL even possible? What am I missing?

First 4 of 4 Posts! Switch mode

erix

erix

Adding my question here, put things into perspective.

I have a file named mysql.ex in my lib folder, with then contents:

defmodule Cc.Mysql do
  use Ecto.Repo,
    otp_app: :cc,
    adapter: Ecto.Adapters.Mariaex
end

because I use Cc.Mysql to interact with the database.

Changing to:

defmodule Cc.Mysql do
  use Ecto.Repo,
    otp_app: :cc,
    adapter: Ecto.Adapters.MyXQL
end

fixed all the errors.

erix

erix

Well.. it fixed the compile errors.

Now I’m faced with a new error. Following the instructions on MyXQL Github README.md I entered the first test command:
iex(1)> {:ok, pid} = MyXQL.start_link(username: "root")
and got the following result:

iex(1)> {:ok, pid} = MyXQL.start_link(username: "root")
{:ok, #PID<0.207.0>}
iex(2)>
12:33:21.854 [error] MyXQL.Connection (#PID<0.209.0>) failed to connect: ** (DBConnection.ConnectionError) (/tmp/mysql.sock) address family not supported by protocol family - :eafnosupport
iex(2)>
12:33:24.662 [error] MyXQL.Connection (#PID<0.209.0>) failed to connect: ** (DBConnection.ConnectionError) (/tmp/mysql.sock) address family not supported by protocol family - :eafnosupport

I am using MySQL 8.1 server from the MySQL site, installed on Win11. The bin is in PATH. What am I missing?

wojtekmach

wojtekmach

Hex Core Team

As you can see from the error message, MyXQL is trying to connect using UNIX socket at /tmp/mysql.sock. You probably want to connect over the network instead, either set protocol: :tcp or explicitly set the hostname: hostname: "localhost" (which implies protocol: :tcp)

erix

erix

Thanks @wojtekmach.

I modified the command to:
{:ok, pid} = MyXQL.start_link(username: "ecto", password: "ecto", protocol: :tcp)
and the connection was established.

Where Next?

Trending in Questions Top

jonnycharles
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
spammy
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
silverdr
Using Phoenix.LiveView.TagEngine as an EEx.Engine is deprecated! To compile HEEx, use Phoenix.LiveView.TagEngine.compile/2 instead. Sta...
New
saveman71
Hello ! We want new/edit form pages to POST/PUT to their own URL rather than the resources REST defaults (post /things, put /things/:id)...
New
dli
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app? Looking for hints regarding: Addi...
New
bottlenecked
Hi all, I wanted to ask how the community is dealing with post-release steps. Today we have Ecto migrations, which make sure that the db...
New
michallepicki
I am using Oban and occasionally, shortly after a deployment, a handful of jobs can fail because of dependency on other parts of the syst...
New

Other Trending Topics Top

preciz
I had a lot of back and forth with Codex CLI &amp; GPT 5.6 Sol to use a SWAR optimization in URI module. I now have a version that on my...
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge &amp; Solve. They are GUI (Emerge) and State management (S...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
type1fool
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New

We're in Beta

About us Mission Statement