elixir-sqlite / ecto_sqlite3

An Ecto SQLite3 adapter.
https://hexdocs.pm/ecto_sqlite3
MIT License
295 stars 43 forks source link

EctoSQLite3.MixProject.project/0 is undefined (module EctoSQLite3.MixProject is not available) #109

Closed gazzer82 closed 10 months ago

gazzer82 commented 1 year ago

I am trying to use EctoSQLite3 in a phoenix project:

      {:phoenix, "~> 1.7.1"},
      {:phoenix_ecto, "~> 4.4"},
      {:ecto_sql, "~> 3.6"},
      {:postgrex, ">= 0.0.0"},

I am getting the following error from ElixirLS

EctoSQLite3.MixProject.project/0 is undefined (module EctoSQLite3.MixProject is not available)

This seems to happen with a completely vanilla Phoenix project created with:

mix phx.new test --database sqlite3

The biggest variable here, is I am on an m1 MacBook Pro, so exqlite is being compile to aarch64-apple-darwin rather that using a precompiled binary, maybe?

Everything does seem to be working as expected, but my ocd needs to clear the error . . .

Thanks!

warmwaffles commented 1 year ago

Hmm, this seems like an upstream generator issue with phoenix.

You need to swap out postgrex with ecto_sqlite3 which will then bring the project in and it will find that MixProject module.

EDIT: probably somewhere in here https://github.com/phoenixframework/phoenix/blob/c9abd2c9a03a3f8529496995e19d3f1e4b06433c/installer/lib/mix/tasks/phx.new.ex

gazzer82 commented 1 year ago

Thanks for the reply.

My mix.exs currently has these deps, so I don't have postgrex as a dependent any more, so not sure where I need to swap it our from?

  defp deps do
    [
      {:phoenix, "~> 1.7.1"},
      {:phoenix_ecto, "~> 4.4"},
      {:ecto_sql, "~> 3.6"},
      {:ecto_sqlite3, ">= 0.0.0"},
      {:phoenix_html, "~> 3.3"},
      {:phoenix_live_reload, "~> 1.2", runtime: Mix.env() == :dev && Mix.target() == :host},
      {:phoenix_live_view, "~> 0.18.16"},
      {:floki, ">= 0.30.0", only: :test},
      {:phoenix_live_dashboard, "~> 0.7.2"},
      {:esbuild, "~> 0.5", runtime: Mix.env() == :dev && Mix.target() == :host},
      {:tailwind, "~> 0.1.8", runtime: Mix.env() == :dev && Mix.target() == :host},
      {:telemetry_metrics, "~> 0.6"},
      {:telemetry_poller, "~> 1.0"},
      {:gettext, "~> 0.20"},
      {:jason, "~> 1.2"},
      {:plug_cowboy, "~> 2.5"},
      {:net_address, "~> 0.2.0"},
      {:cubdb, "~> 2.0"},
      {:ecto_fields, "~> 1.3.0"},
      {:logger_file_backend, "~> 0.0.10"},
      {:codec, "~> 0.1.2"},
      {:binary, "~> 0.0.5"},
      {:struct_access, "~> 1.1.2"},
      {:ecto_sqlite3_extras, "~> 1.2.0"}
    ]
  end
warmwaffles commented 1 year ago

@gazzer82 are you able to push the project up to github so I can check it out and help?

joeljuca commented 1 year ago

I do have a MacBook Pro M1 too, and I cannot reproduce this error. I just created a project with the following command:

$ mix phx.new --database sqlite3 issue109

@gazzer82 would you mind telling us which version of Elixir and Erlang you're using? And, could you update your phx_new with the following command and try it again?

$ mix archive.install hex phx_new

FYI, my Erlang and Elixir versions are:

$ asdf list
elixir
 *1.14.4-otp-25
erlang
 *25.3
joeljuca commented 1 year ago

I just ran some more tests. Projects created with a recent version of phx.new seem to be configured appropriately and work fine. This might be an issue with an outdated Phoenix generator (most probably), or some issue with Elixir versions (least probably).