Skip to content

phx.gen.live doesn't work in umbrella app #4566

@cjbottaro

Description

@cjbottaro
$ mix phx.gen.live Signup
** (Mix) mix phx.gen.live must be invoked from within your *_web application root directory

$ cd apps/web

$ mix phx.gen.live --no-context --no-schema Signup
** (Mix) Invalid arguments

mix phx.gen.html, phx.gen.json, phx.gen.live, and phx.gen.context
expect a context module name, followed by singular and plural names
of the generated resource, ending with any number of attributes.
For example:

    mix phx.gen.html Accounts User users name:string
    mix phx.gen.json Accounts User users name:string
    mix phx.gen.live Accounts User users name:string
    mix phx.gen.context Accounts User users name:string

The context serves as the API boundary for the given resource.
Multiple resources may belong to a context and a resource may be
split over distinct contexts (such as Accounts.User and Payments.User).

$ mix phx.gen.live --no-context --no-schema Foo Signup users
** (Mix) no context_app configured for current application web.

Add the context_app generators config in config.exs, or pass the
--context-app option explicitly to the generators. For example:

via config:

    config :web, :generators,
      context_app: :some_app

via cli option:

    mix phx.gen.[task] --context-app some_app

Note: cli option only works when `context_app` is not set to `false`
in the config.

# add to my config/config.exs: config :web, :generators, context_app: :web

$ mix phx.gen.live --no-context --no-schema --context-app web Foo Signup users
* creating lib/web_web/live/signup_live/show.ex
* creating lib/web_web/live/signup_live/index.ex
* creating lib/web_web/live/signup_live/form_component.ex
* creating lib/web_web/live/signup_live/form_component.html.heex
* creating lib/web_web/live/signup_live/index.html.heex
* creating lib/web_web/live/signup_live/show.html.heex
* creating test/web_web/live/signup_live_test.exs
* creating lib/web_web/live/modal_component.ex
* creating lib/web_web/live/live_helpers.ex
** (File.Error) could not read file "lib/web_web.ex": no such file or directory
    (elixir 1.12.3) lib/file.ex:355: File.read!/1
    lib/mix/tasks/phx.gen.live.ex:151: Mix.Tasks.Phx.Gen.Live.maybe_inject_helpers/1
    lib/mix/tasks/phx.gen.live.ex:103: Mix.Tasks.Phx.Gen.Live.run/1
    (mix 1.12.3) lib/mix/task.ex:394: anonymous fn/3 in Mix.Task.run_task/3
    (mix 1.12.3) lib/mix/cli.ex:84: Mix.CLI.run_task/2

It finally generates some things, but crashes before it finishes. Further, it seems to completely ignore --no-context and --no-schema.

I'm using Phoenix 1.6.2.

Thanks for the help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions