kipcole9 / money_sql

Money functions for the serialization of a money data type in Elixir
Other
28 stars 18 forks source link

`undefined function migrations_path/1` when attempting to compile #2

Closed davidsulc closed 5 years ago

davidsulc commented 5 years ago

I ran in to https://github.com/kipcole9/money_sql/issues/1, but before seeing the issue I tried to clean my deps, refetch and recompile them.

Now, running mix deps.compile yields

== Compilation error in file lib/mix/tasks/money_gen_aggregate_functions.ex ==
** (CompileError) lib/mix/tasks/money_gen_aggregate_functions.ex:30: undefined function migrations_path/1
    (elixir) src/elixir_locals.erl:107: :elixir_locals."-ensure_no_undefined_local/3-lc$^0/1-0-"/2
    (elixir) src/elixir_locals.erl:107: anonymous fn/3 in :elixir_locals.ensure_no_undefined_local/3
could not compile dependency :ex_money_sql, "mix compile" failed. You can recompile this dependency with "mix deps.compile ex_money_sql", update it with "mix deps.update ex_money_sql" or clean it with "mix deps.clean ex_money_sql"

I'm able to compile when only ex_money is listed as a dependency, but not once I add ex_money_sql.

I'm using {:ecto_sql, "~> 3.0"}.

If I don't include ex_money_sql (so I can compile), and poke around in iex it appears that among the conditional clauses in https://github.com/kipcole9/money_sql/blob/master/lib/money/migration.ex have the following values: line 4 true, line 10 false, line 16 true.

Let me know if I can provide any other relevant info.

===

If I use the master branch as the dependency, I get the same error. But after commenting lines 4 and 8 in https://github.com/kipcole9/money_sql/blob/master/lib/money/migration.ex, I get the following when recompiling:

==> ecto
Compiling 54 files (.ex)
Generated ecto app
==> ex_cldr_currencies
Compiling 2 files (.ex)
Generated ex_cldr_currencies app
==> ex_cldr_numbers
Compiling 4 files (.erl)
Compiling 24 files (.ex)
Generated ex_cldr_numbers app
==> ex_money
Compiling 20 files (.ex)
warning: function Ecto.Migrator.migrations_path/1 is undefined (module Ecto.Migrator is not available)
  lib/money/migration.ex:5

Generated ex_money app
==> postgrex
Compiling 61 files (.ex)
Generated postgrex app
==> ecto_sql
Compiling 25 files (.ex)
Generated ecto_sql app
==> ex_money_sql
Compiling 7 files (.ex)
warning: redefining module Money.Migration (current version loaded from /home/david/Documents/dev/coinage_guru/ingestion_engine/_build/dev/lib/ex_money/ebin/Elixir.Money.Migration.beam)
  lib/money/migration.ex:1

Sooo, using the master branch of BOTH ex_money and ex_money_sql (and using override: true in ex_money to override the version specified as the ex_money_sql dependency), I then run in to issue #1 (so I guess it's not fixed on master?).

Then, I can apply the work around indicate there:

cp -r my_project_dir/_build/dev/lib/ex_money_sql/priv/SQL/postgres/* my_project_dir/_build/dev/lib/ex_money/priv/SQL/postgres/

And THEN the migration works. So it seems that once the migration looks for the files in the right place (or they are moved to where they're expected), bumping version numbers on both packages should solve the issues.

kipcole9 commented 5 years ago

I have the fix developed in master and will release in the next 24 hours after I build some more tests. Apologies for taking so long on this.

kipcole9 commented 5 years ago

I have pushed a new release and published version 1.1.0 to hex that I believe resolves this issue, and that of #1.

davidsulc commented 5 years ago

Thanks for your great work!

I've tested the new version and it works as expected modulo an incorrect task name in the docs: https://github.com/kipcole9/money_sql/pull/3