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

冷暖自知 提交于 2019-12-24 10:55:34

问题


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? I also want to be able to use "iex -S mix" with it. 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.

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. I'm also using kiex and kerl for elixir version configuration.

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

回答1:


You need use the local elixir binary.

For example, instead of iex -S mix phx.server, do $YOUR_LOCAL_ELIXIR_PATH/bin/iex -S mix phx.server. Other stuff like mix, elixir are the same.




回答2:


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.

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. I would name (amongst others);

  • https://github.com/asdf-vm/asdf
  • https://github.com/taylor/kiex
  • https://github.com/mururu/exenv

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.



来源:https://stackoverflow.com/questions/45405710/how-do-i-point-to-a-local-elixir-version-in-mix-exs-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!