重命名Elixir / Phoenix Codebase:变量" X"不存在,正在扩展到" X()"

时间:2017-07-25 14:45:19

标签: elixir phoenix-framework

我将我的代码库从Livestory重命名为Citybuilder。我在文件中的文本中使用了find和replace,然后使用mv重命名目录。 Livestory的代码库搜索返回零结果。 https://stackoverflow.com/editing-help

当我运行mix phx.server时,我得到:

variable "citybuilder" does not exist and is being expanded to "citybuilder()", please use parentheses to remove the ambiguity or change the variable name
  mix.exs:1

我尝试了mix deps.cleanmix deps.get。同样的结果" citybuilder不存在"。

我在这里发现了一个类似的问题,但它并不适用于我,因为我正在运行最新版本的Elixir和Phoenix:

Phoenix setup failing: Compilation error, (KeyError) key :model not found

*

Mix.exs

defmodule citybuilder.Mixfile do
  use Mix.Project

  def project do
    [app: :citybuilder,
     version: "0.0.1",
     elixir: "~> 1.4",
     elixirc_paths: elixirc_paths(Mix.env),
     compilers: [:phoenix, :gettext] ++ Mix.compilers,
     build_embedded: Mix.env == :prod,
     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: {citybuilder.Application,  []},
      applications: [
        :logger, :postgrex, :ecto, :timex, :phoenix, :phoenix_html, :phoenix_pubsub,
        :phoenix_ecto, :cowboy, :gettext, :guardian, :comeonin, :recaptcha, :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-rc", override: true},
     {:phoenix_pubsub, "~> 1.0"},
     {:phoenix_ecto, "~> 3.2"},
     {:postgrex, ">= 0.0.0"},
     {:phoenix_html, "~> 2.6"},
     # from official repository, but not from hex, because latest patches are not released yet
     {:recaptcha, "~> 2.0", github: "samueljseay/recaptcha"},
     {:timex, "~> 3.0"},
     {:phoenix_live_reload, "~> 1.0", only: :dev},
     {:gettext, "~> 0.11"},
     {:cowboy, "~> 1.0"},
     {:guardian, "~> 0.14"},
     {:comeonin, "~> 3.0"},
     {:distillery, "~> 1.0"},
     {:edeliver, "~> 1.4.0"}]
  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

1 个答案:

答案 0 :(得分:2)

我做了一个不区分大小写的搜索和替换,Livestory成了citybuilder(而不是Citybuilder。)Elixir不认可citybuilder作为原子,而是尝试查找citybuilder变量,最后调用citybuilder函数。

我通过在Citybuilder中找到并替换citybuilder来解决这个问题。

注意:有一些应用程序,比如postgres,需要citybuilder为小写。