简体   繁体   English

如何在mix.exs文件中指向本地灵丹妙药版本?

[英]How do I point to a local elixir version in mix.exs file?

So I have a phoenix project I'm using as a test app of sorts. 因此,我有一个凤凰项目正在用作各种测试应用程序。 If I want to use a local version of elixir source code that I'm using (and making changes on), how do I tell phoenix to use it? 如果我想使用正在使用的本地版本的elixir源代码(并进行更改),如何告诉phoenix使用它? I also want to be able to use "iex -S mix" with it. 我还希望能够将其与“ iex -S mix”一起使用。 The below elixir: ["~> 1.6.0-dev", path: '/my/local/path/to/elixir'] does not work, but it's what I'm trying to do. 下面的elixir: ["~> 1.6.0-dev", path: '/my/local/path/to/elixir']不起作用,但这是我想要的。

I already tried adding the below and I get a syntax error. 我已经尝试添加以下内容,但出现语法错误。 Adding elixir to the dependencies (in the def deps function) didn't seem to do anything. 将e剂添加到依赖项(在def deps函数中)似乎没有任何作用。 I'm also using kiex and kerl for elixir version configuration. 我还使用kiex和kerl进行长生不老药的版本配置。

defmodule PhoenixTestApp.Mixfile do
  use Mix.Project

  def project do
    [
      app: :phoenix_testbed,
      version: "0.0.1",
      elixir: ["~> 1.6.0-dev", path: '/my/local/path/to/elixir']
      elixirc_paths: elixirc_paths(Mix.env),
      compilers: [:phoenix, :gettext] ++ Mix.compilers,
      start_permanent: Mix.env == :prod,
      aliases: aliases(),
      deps: deps()
    ]
  end
  ## some more default config code generated by Phoenix
  # :
  # :
end

You need use the local elixir binary. 您需要使用本地elixir二进制文件。

For example, instead of iex -S mix phx.server , do $YOUR_LOCAL_ELIXIR_PATH/bin/iex -S mix phx.server . 例如,而不是iex -S mix phx.server ,做$YOUR_LOCAL_ELIXIR_PATH/bin/iex -S mix phx.server Other stuff like mix , elixir are the same. 其他类似mixelixir东西是相同的。

Your project is being run by elixir / iex already, so there is a chicken-egg problem trying to set an elixir / iex version from inside mix.exs file. 您的项目已经由elixir / iex运行,因此尝试从mix.exs文件中设置elixir / iex版本时mix.exs了鸡问题。

It's more the property of the operating system, rather than the project, to select an environment. 选择环境更多的是操作系统的属性,而不是项目的属性。 There are many different elixir / erlang version managers out in the wild. 有很多不同的elixir / erlang版本管理器。 I would name (amongst others); 我会(在其他人中)命名;

I personally use the latter and I am happy with it. 我个人使用后者,对此我感到满意。 It allows setting a local version per project (with local .exenv file,) a global version, and the easy switch between different versions. 它允许为每个项目设置本地版本(带有本地.exenv文件),全局版本,并可以在不同版本之间轻松切换。

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

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