Search code examples
elixirphoenix-frameworkelixir-mix

Pattern for generating names at command line when using mix to create an app skeleton


I am trying to learn Elixir and am using mix to generate a basic RestFul API skeleton:

% mix new MyApi --module MyApi

I get an error:

** (Mix) Application name must start with a lowercase ASCII letter, followed by lowercase ASCII letters, numbers, or underscores, got: "MyApi". The application name is inferred from the path, if you'd like to explicitly name the application then use the "--app APP" option

then I try this:

% mix new my-in-memory-api  --module MyApi

and I get this error:

** (Mix) Application name must start with a lowercase ASCII letter, followed by lowercase ASCII letters, numbers, or underscores, got: "my-in-memory-api". The application name is inferred from the path, if you'd like to explicitly name the application then use the "--app APP" option


Solution

  • mix new uses the path as the app name by default. In your case, the path has dashes which are not allowed in an app name. To fix, you need to pass a valid app name like this:

    $ mix new my-in-memory-api --app my_in_memory_api --module MyApi