1
votes

I renamed my codebase from Livestory to Citybuilder. I used a find and replace on the text in the files, then mv to rename the directories. A codebase search for Livestory returns zero results. https://stackoverflow.com/editing-help

When I run mix phx.server, I get:

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

I tried running mix deps.clean and mix deps.get. Same result "citybuilder does not exist".

I found a similar question here, but it doesn't apply to me as I'm running the latest versions of Elixir and 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
Can you post the complete contents of mix.exs? - Dogbert
The problem is you made a case-insensitive search and replace and Livestory became citybuilder (instead of Citybuilder.) Elixir does not recognize citybuilder as an atom, instead it tries to lookup citybuilder variable and finally to call citybuilder function. - Aleksei Matiushkin
I knew cases were going to be a problem in this renaming. I used the Find and Replace function in my IDE and didn't check the settings. I'll change that now, thanks. - RubyRube

1 Answers

2
votes

I made a case-insensitive search and replace and Livestory became citybuilder (instead of Citybuilder.) Elixir does not recognize citybuilder as an atom, instead it tries to lookup citybuilder variable and finally to call citybuilder function.

I fixed this by finding and replacing citybuilder with Citybuilder.

Note: There are some applications, like postgres, that require citybuilder to be lowercase.