gjaldon / ecto_enum

Ecto extension to support enums in models
MIT License
562 stars 131 forks source link

Compilation error on file lib/ecto_enum.ex #27

Closed shakthimaan closed 7 years ago

shakthimaan commented 7 years ago

I am getting the following error when running mix ecto.create on a test project:

$ mix ecto.create
==> ecto_enum
Compiled lib/ecto_enum/postgres.ex

== Compilation error on file lib/ecto_enum.ex ==
** (CompileError) lib/ecto_enum.ex:124: type keyword() undefined
    (stdlib) lists.erl:1337: :lists.foreach/2
    (stdlib) erl_eval.erl:669: :erl_eval.do_apply/6

could not compile dependency :ecto_enum, "mix compile" failed. You can recompile this dependency with "mix deps.compile ecto_enum", update it with "mix deps.update ecto_enum" or clean it with "mix deps.clean ecto_enum"

Relevant file contents are shown below:

  1. mix.exs
    defp deps do                                                                                                                        
    [{:phoenix, "~> 1.2.1"},
     {:phoenix_pubsub, "~> 1.0"},
     {:phoenix_ecto, "~> 3.0"},
     {:postgrex, ">= 0.0.0"},
     {:phoenix_html, "~> 2.6"},
     {:phoenix_live_reload, "~> 1.0", only: :dev},
     {:gettext, "~> 0.11"},
     {:cowboy, "~> 1.0"},
     {:comeonin, "~> 2.0"},
     {:ecto_enum, "~> 1.0"}]
    end
  2. lib/my_app/ecto_enums.ex
    import EctoEnum
    defenum DegreeEnum, bachelors: 0, masters: 1 
  3. web/models/user.ex

    defmodule MyApp.User do
    use MyApp.Web, :model
    
    schema "users" do
    ...
    field :degree, DegreeEnum
    ...
    timestamps()
    end

    Using ERL version on Ubuntu 15.04.

    $ erl --version
    Erlang/OTP 18 [erts-7.2] [source-e6dd627] [64-bit] [smp:2:2] [async-threads:10] [hipe] [kernel-poll:false]

    What could I be missing?

shakthimaan commented 7 years ago

Was using an old version of Elixir (1.2.4). Compiles fine on 1.3.4.

gjaldon commented 7 years ago

@shakthimaan that's correct. EctoEnum 1.0 only works with Elixir 1.3.