【问题标题】:'Task could not be found' for custom mix task自定义混合任务的“找不到任务”
【发布时间】:2015-11-13 06:42:25
【问题描述】:

我在 lib/mix/tasks/thing.exs 中有一个任务 Thing

代码是:

defmodule Mix.Tasks.Thing do
  use Mix.Task

  def run(_) do
    IO.puts "hello world"
  end

end

当我运行mix thingmix Thing 时,我得到The task thing could not be foundThe task Thing could not be found

我之前尝试过运行mix compile,但没有帮助。

我还尝试将 this question 中的代码直接放入我的 mix.exs,如该问题所示。我仍然无法运行任务。

【问题讨论】:

    标签: elixir elixir-mix


    【解决方案1】:

    混合任务需要编译。如果您从 lib/mix/tasks/thing.exs 重命名为 lib/mix/tasks/thing.ex,那么它应该可以工作。

    您可以阅读更多关于脚本模式 (.exs) 的信息:http://elixir-lang.org/getting-started/modules.html#scripted-mode

    【讨论】:

      猜你喜欢
      • 2017-02-11
      • 2016-07-07
      • 2017-10-16
      • 2018-11-09
      • 2017-05-30
      • 2019-10-23
      • 2019-06-24
      • 2018-01-30
      • 2021-10-03
      相关资源
      最近更新 更多