[英]'Task could not be found' for custom mix task
I have a task Thing in lib/mix/tasks/thing.exs 我有一个任务在lib / mix / tasks / thing.exs
The code is: 代码是:
defmodule Mix.Tasks.Thing do
use Mix.Task
def run(_) do
IO.puts "hello world"
end
end
When I run mix thing
or mix Thing
I get The task thing could not be found
or The task Thing could not be found
当我运行mix thing
或mix Thing
我得到The task thing could not be found
或The task Thing could not be found
I've tried running mix compile
beforehand, which didn't help. 我已经尝试过预先运行mix compile
,这没有用。
I also tried putting the code from this question directly into my mix.exs, as shown in that question. 我也尝试将这个问题的代码直接放到我的mix.exs中,如该问题所示。 I still couldn't run the task. 我仍然无法执行任务。
Mix tasks need to be compiled. 需要编译混合任务。 If you rename from lib/mix/tasks/thing.exs
to lib/mix/tasks/thing.ex
then it should work. 如果你从lib/mix/tasks/thing.exs
重命名为lib/mix/tasks/thing.ex
那么它应该可以工作。
You can read more about scripted mode (.exs) at: http://elixir-lang.org/getting-started/modules.html#scripted-mode 您可以在以下网址阅读有关脚本模式(.exs)的更多信息: http ://elixir-lang.org/getting-started/modules.html#scripted-mode
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.