简体   繁体   English

找不到混合任务“发布”错误

[英]Mix task “release” not found error

I was setting up an Ubuntu 16.04 server for my Elixir/Phoenix application with edeliver when edeliver failed with the error message ** (Mix) The task "release" could not be found along with a exit code of 1. If I go to my build server, git pull my app and run MIX_ENV=prod mix release or just mix release after getting dependencies, I get the same error. 当edeliver失败并显示错误消息** (Mix) The task "release" could not be found时,我使用edeliver为我的Elixir / Phoenix应用程序设置了Ubuntu 16.04服务器。找不到** (Mix) The task "release" could not be found ,退出代码为1。构建服务器,git拉我的应用程序并运行MIX_ENV=prod mix release或者仅在获得依赖项后才mix release ,我遇到相同的错误。

However, the same application works without any problem locally. 但是,同一应用程序可以在本地正常运行。

My erlang version is erts-9.0 and elixir version is 1.5.5 on both the server and my local computer. 我的erlang版本是erts-9.0 ,而服务器和本地计算机上的elixir版本都是1.5.5 Hex version is also the same at 0.16.1 . 十六进制版本也与0.16.1相同。

Phoenix was installed using this command: mix archive.install https://github.com/phoenixframework/archives/raw/master/phx_new.ez . 使用以下命令安装了Phoenix: mix archive.install https://github.com/phoenixframework/archives/raw/master/phx_new.ez

This is my mix.exs file. 这是我的mix.exs文件。

defmodule MyApp.Mixfile do
  use Mix.Project

  def project do
    [
      app: :MyApp,
      version: "0.0.1",
      elixir: "~> 1.4",
      elixirc_paths: elixirc_paths(Mix.env),
      compilers: [:phoenix, :gettext] ++ Mix.compilers,
      start_permanent: Mix.env == :prod,
      aliases: aliases(),
      deps: deps()
    ]
  end

  # Configuration for the OTP application.
  #
  # Type `mix help compile.app` for more information.
  def application do
    [
      mod: {MyApp.Application, []},
      extra_applications: [:comeonin, :logger, :runtime_tools, :earmark, :distillery, :edeliver]
    ]
  end

  # Specifies which paths to compile per environment.
  defp elixirc_paths(:test), do: ["lib", "test/support"]
  defp elixirc_paths(_),     do: ["lib"]

  # Specifies your project dependencies.
  #
  # Type `mix help deps` for examples and options.
  defp deps do
    [
      {:phoenix, "~> 1.3.0"},
      {:phoenix_pubsub, "~> 1.0"},
      {:phoenix_ecto, "~> 3.2"},
      {:mariaex, ">= 0.0.0"},
      {:phoenix_html, "~> 2.10"},
      {:comeonin, "~> 4.0"},
      {:phoenix_live_reload, "~> 1.0", only: :dev},
      {:gettext, "~> 0.11"},
      {:earmark, "~> 1.2.3"},
      {:cowboy, "~> 1.0"},
      {:edeliver, "~> 1.4.4"},
      {:distillery, "~> 1.5.1"}
    ]
  end

  # Aliases are shortcuts or tasks specific to the current project.
  # For example, to create, migrate and run the seeds file at once:
  #
  #     $ mix ecto.setup
  #
  # See the documentation for `Mix` for more info on aliases.
  defp aliases do
    [
      "ecto.setup": ["ecto.create", "ecto.migrate", "run priv/repo/seeds.exs"],
      "ecto.reset": ["ecto.drop", "ecto.setup"],
      "test": ["ecto.create --quiet", "ecto.migrate", "test"]
    ]
  end
end

My edeliver configuration file .deliver/config is as follows: 我的edeliver配置文件.deliver/config如下:

APP="MyApp"

BUILD_HOST="1.1.1.1"
BUILD_USER="ubuntu"
BUILD_AT="/home/ubuntu/app_build"

PRODUCTION_HOSTS="1.1.1.1" 
PRODUCTION_USER="ubuntu" 
DELIVER_TO="/home/ubuntu/app_release" 

pre_erlang_get_and_update_deps() {
  local _prod_secret_path="/home/ubuntu/app_config/prod.secret.exs"
  if [ "$TARGET_MIX_ENV" = "prod" ]; then
    __sync_remote "
      ln -sfn '$_prod_secret_path' '$BUILD_AT/config/prod.secret.exs'
    "
  fi
}

TLDR: point your branch explicitly and make sure, that folder /rel/ under git and committed: TLDR:明确指向分支,并确保git下的/rel/文件夹已提交:

$ mix edeliver build release --branch=feature/deploy

I had similar error: ** (Mix) The task "release" could not be found and when I tried to find a solution, this unresolved discussion got my attention several times. 我有类似的错误: ** (Mix) The task "release" could not be found ,当我尝试找到解决方案时,这个悬而未决的讨论引起了我多次注意。 I realized, that mix task release is in the /rel/config.exs . 我意识到,混合任务release/rel/config.exs And if you use command $ mix edeliver build release as mentioned in literally all tutorials, edeliver gets master branch version (no matter from what branch you try to build). 而且,如果您按字面所有教程中所述使用命令$ mix edeliver build release ,则edeliver将获得master分支版本(无论您尝试从哪个分支进行构建)。

As far as I can see, you are using edeliver to deliver the application to the server. 据我edeliver ,您正在使用edeliver将应用程序交付到服务器。 Why would you run anything from the server then? 那为什么还要从服务器运行任何东西?

Also, where release task should come from? 另外, release任务应该来自哪里? I believe, you did mean something like: 我相信,您的意思确实是这样的:

mix edeliver build release
mix edeliver deploy release to production
mix edeliver restart production

which is the standard flow to build, deploy and restart production with edeliver . 这是使用edeliver构建,部署和重新启动生产的标准流程。 Unfortunately, the three commands above won't work out of the box as well, and you will need to explicitly setup edeliver for phoenix project (there are many good tutorials all around.) 不幸的是,上面的三个命令也不是edeliver可用的,您将需要为phoenix项目显式设置edeliver (到处都有很多很好的教程。)

The problem I had was I forgot to push the latest changes to git which it does fetch the source from. 我遇到的问题是我忘了将最新的更改推到git中,它确实从中获取源代码。 So after adding the edeliver it couldnt find any of the files its generated. 因此,在添加edeliver之后,它无法找到其生成的任何文件。 By pushing it to git it now works for me. 通过将其推送到git,现在对我有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM