Variable "test" does not exist and is being expanded to, please use parentheses to remove the ambiguity or change the variable name

Newbee to Elixir Phonenix, followed https://github.com/mirego/elixir-boilerplate page to create first Elixir project, however while running make dependencies step, get this error. Tried searching for answer but cant able to find any. Someone please help me here

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

** (CompileError) mix.exs:1: undefined function test/0
    (stdlib 3.17) lists.erl:1358: :lists.mapfoldl/3
    (stdlib 3.17) lists.erl:1358: :lists.mapfoldl/3
    (elixir 1.12.2) expanding macro: Kernel.defmodule/2
make: *** [Makefile:82: dependencies] Error 1
root@Raghul:/home/raghul/git/test/elixir-boilerplate#

first portion of the mix.exs file given below

defmodule test.Mixfile do
  use Mix.Project

  def project do
    [
      app: :test,
      version: "0.0.1",
      erlang: "~> 25.0",
      elixir: "~> 1.13",
      elixirc_paths: elixirc_paths(Mix.env()),
      test_paths: ["test"],
      test_pattern: "**/*_test.exs",
      test_coverage: [tool: ExCoveralls],
      preferred_cli_env: [coveralls: :test, "coveralls.detail": :test, "coveralls.post": :test, "coveralls.html": :test],
      start_permanent: Mix.env() == :prod,
      aliases: aliases(),
      deps: deps(),
      dialyzer: dialyzer(),
      releases: releases()
    ]
  end

Welcome to the forum, and to Elixir.

I’m not familiar with the repo you refer to, it’s more common to start a new project with mix new.

If you look at the first line of your module you’ll see:

defmodule test.Mixfile do

In Elixir syntax, an all lower-case identifier is a variable. Module names start with an uppercase letter. Therefore Elixir is trying to resolve the variable test and finding it does not exist. The module name should probably be Test.Mixfile.

2 Likes

+1 what kip said. Also, call your project something other than “test”. Even if you are just experimenting, it is not fun to use an already overloaded word. I suggest finding a word that is “your word”. For example, I use the word “hyu” for names of experimental projects, or draft functions. These 3 letters in this order are rare to find in any codebase. It makes it super easy to rename my project or function later.

You will notice the project name gets unwieldy when you start writing tests. Following mix project structure convention, your tests will live in files like ~/my-github-projects/test/test/test_test.exs. :frowning: Nicer to have ~/my-github-projects/hyu/test/hyu_test.exs, for example.

2 Likes