Skip to content

Error when generating Ecto migration with Gleam compiler added #40

@digzom

Description

@digzom

Hey there,

I'm encountering an issue when trying to generate an ecto migration.

When I add the Gleam compiler to the compilers list in mix.exs file and try to run mix ecto.gen.migration <migration_name>, I receive this error:

** (Mix) Unknown dependency <migration_name> for environment <my_mix_env_value>

Steps to Reproduce:

  1. In a Mix project that uses Ecto, add the :gleam compiler to the compilers list in the mix.exs file.
  2. Attempt to run mix ecto.gen.migration.

Expected Behavior:
The migration should be generated normally without any errors.

Environment:

  • Library Version: mix_gleam 0.6.2
  • Operating System: Linux Ubuntu 22.04
  • Gleam 1.0.0
  • Elixir 1.16.1
  • Erlang 26.1

Mix file

defmodule PayCosern.MixProject do
  use Mix.Project

  @app_name :pay_cosern

  def project do
    [
      app: :pay_cosern,
      version: "0.1.0",
      elixir: "~> 1.16.1",
      name: "#{@app_name}",
      archives: [mix_gleam: "~> 0.6.2"],
      compilers: [:gleam] ++ Mix.compilers(),
      releases: [
        pay_cosern: [
          applications: [ex_unit: :permanent]
        ]
      ],
      erlc_paths: [
        "build/dev/erlang/#{@app_name}/_gleam_artefacts"
      ],
      erlc_include_path: "build/dev/erlang/#{@app_name}/include",
      prune_code_paths: false,
      deps: deps(),
      aliases: aliases()
    ]
  end

  defp aliases() do
    [
      "ecto.setup": ["ecto.create", "ecto.migrate"],
      "ecto.reset": ["ecto.drop", "ecto.setup"],
      "deps.get": ["deps.get", "gleam.deps.get"]
    ]
  end

  # Run "mix help compile.app" to learn about applications.
  def application do
    [
      extra_applications: [:logger, :ecto, :cowboy, :plug],
      mod: {PayCosern.Application, []}
    ]
  end

  # Run "mix help deps" to learn about dependencies.
  defp deps do
    [
      {:ecto_sql, "~>  3.6"},
      {:postgrex, ">=  0.0.0"},
      {:floki, "~> 0.35.0"},
      {:plug, "~>  1.12"},
      {:cowboy, "~>  2.9"},
      {:plug_cowboy, "~> 2.0"},
      {:jason, "~> 1.2.2"},
      {:wallaby, "~> 0.30", runtime: true},
      {:oban, "~> 2.16"},
      {:poolboy, "~> 1.5.2"},
      {:ecto_sqlite3, "~> 0.13"},
      {:timex, "~> 3.0"},
      {:argon2_elixir, "~> 4.0"},
      {:guardian, "~> 2.3.2"},
      {:gleam_stdlib, "~> 0.34 or ~> 1.0"},
      {:gleeunit, "~> 1.0", only: [:dev, :test], runtime: false}
    ]
  end
end

Screen gif

In this gif I first tried using the 'compilers' key. Then, I tried again with compilers commented and worked.

Screen recording (7)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions