Skip to content

phx.new with --no-html problem #327

@namjae

Description

@namjae

Versions

I initialized the project as an API-only application using the --no-html --no-assets options, so the browser pipeline isn't required. However, I noticed that router.ex still includes a reference to it by default.

~/tmp $ mix igniter.new my_api --with phx.new --with-args="--no-html --no-assets" --install ash,ash_phoenix \
  --install ash_graphql,ash_postgres --install ash_admin --yes
* creating my_api/lib/my_api/application.ex
* creating my_api/lib/my_api.ex
* creating my_api/lib/my_api_web/controllers/error_json.ex
* creating my_api/lib/my_api_web/endpoint.ex
* creating my_api/lib/my_api_web/router.ex
* creating my_api/lib/my_api_web/telemetry.ex
* creating my_api/lib/my_api_web.ex
* creating my_api/mix.exs
* creating my_api/README.md
* creating my_api/.formatter.exs
* creating my_api/.gitignore
* creating my_api/test/support/conn_case.ex
* creating my_api/test/test_helper.exs
* creating my_api/test/my_api_web/controllers/error_json_test.exs
* creating my_api/lib/my_api/repo.ex
* creating my_api/priv/repo/migrations/.formatter.exs
* creating my_api/priv/repo/seeds.exs
* creating my_api/test/support/data_case.ex
* creating my_api/lib/my_api/mailer.ex
* creating my_api/lib/my_api_web/gettext.ex
* creating my_api/priv/gettext/en/LC_MESSAGES/errors.po
* creating my_api/priv/gettext/errors.pot
* creating my_api/priv/static/robots.txt
* creating my_api/priv/static/favicon.ico
* running mix deps.get
* running mix deps.compile

We are almost there! The following steps are missing:

    $ cd my_api

Then configure your database in config/dev.exs and run:

    $ mix ecto.create

Start your Phoenix app with:

    $ mix phx.server

You can also run your app inside IEx (Interactive Elixir) as:

    $ iex -S mix phx.server

Fetching and compiling dependencies ✔
Updating project's igniter dependency ✔
installing igniter ✔
temporarily adding igniter ✔
compiling igniter ✔
setting up igniter ✔
compiling 5 packages ✔
`ash.install` ✔
`ash_phoenix.install` ✔
installing new dependencies ✔
`ash_graphql.install` ✔
`ash_postgres.install` ✔
`ash_admin.install` ✔
Resolving Hex dependencies...
Resolution completed in 0.459s
Unchanged:
  absinthe 1.7.10
  absinthe_phoenix 2.0.3
  absinthe_plug 1.5.9
  ash 3.5.23
  ash_admin 0.13.10
  ash_graphql 1.7.15
  ash_phoenix 2.3.7
  ash_postgres 2.6.8
  ash_sql 0.2.82
  bandit 1.7.0
  db_connection 2.7.0
  decimal 2.3.0
  dns_cluster 0.1.3
  ecto 3.13.1
  ecto_sql 3.13.1
  ets 0.9.0
  expo 1.1.0
  finch 0.19.0
  gettext 0.26.2
  glob_ex 0.1.11
  hpax 1.0.3
  igniter 0.6.7
  iterex 0.1.2
  jason 1.4.4
  libgraph 0.16.0
  mime 2.0.7
  mint 1.7.1
  nimble_options 1.1.1
  nimble_parsec 1.4.2
  nimble_pool 1.1.0
  owl 0.12.2
  phoenix 1.8.0-rc.3
  phoenix_ecto 4.6.4
  phoenix_html 4.2.1
  phoenix_live_dashboard 0.8.7
  phoenix_live_view 1.0.17
  phoenix_pubsub 2.1.3
  phoenix_template 1.0.4
  phoenix_view 2.0.4
  plug 1.18.0
  plug_crypto 2.1.1
  postgrex 0.20.0
  reactor 0.15.5
  req 0.5.10
  rewrite 1.1.2
  sourceror 1.10.0
  spark 2.2.66
  spitfire 0.2.1
  splode 0.2.9
  stream_data 1.2.0
  swoosh 1.19.3
  telemetry 1.3.0
  telemetry_metrics 1.1.0
  telemetry_poller 1.2.0
  text_diff 0.1.0
  thousand_island 1.3.14
  websock 0.5.3
  websock_adapter 0.5.8
  yamerl 0.10.0
  yaml_elixir 2.11.0
  ymlr 5.1.3
All dependencies are up to date
==> ash
Compiling 529 files (.ex)
Compiling lib/ash/reactor/reactor.ex (it's taking more than 10s)
Generated ash app
==> ash_graphql
Compiling 47 files (.ex)
Generated ash_graphql app
==> ash_phoenix
Compiling 34 files (.ex)
Generated ash_phoenix app
==> my_api
Compiling 12 files (.ex)
    error: undefined function browser/2 (expected MyApiWeb.Router to define such a function or for it to be imported, but none are available)
    │
  1 │ defmodule Phoenix.Router do
    │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^
    │
    └─ deps/phoenix/lib/phoenix/router.ex:1: MyApiWeb.Router.__pipe_through2__/1


== Compilation error in file lib/my_api_web/router.ex ==
** (CompileError) lib/my_api_web/router.ex: cannot compile module MyApiWeb.Router (errors have been logged)


Notices: 

* A `min_pg_version/0` function has been defined in
  `MyApi.Repo` automatically.
  
  You may wish to update this configuration. It should
  be set to the lowest version that your application
  expects to be run against.
  

Notices were printed above. Please read them all before continuing!

Successfully installed:

* ash
* ash_phoenix
* ash_graphql
* ash_postgres
* ash_admin
~/tmp $ 

Operating system

Ubuntu 24.04.2 LTS

Current Behavior

outputs an error

   error: undefined function browser/2 (expected MyApiWeb.Router to define such a function or for it to be imported, but none are available)
    │
  1 │ defmodule Phoenix.Router do
    │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^
    │
    └─ deps/phoenix/lib/phoenix/router.ex:1: MyApiWeb.Router.__pipe_through2__/1


== Compilation error in file lib/my_api_web/router.ex ==
** (CompileError) lib/my_api_web/router.ex: cannot compile module MyApiWeb.Router (errors have been logged)

Reproduction

just enter the following command in command line

mix igniter.new my_api --with phx.new --with-args="--no-html --no-assets" --install ash,ash_phoenix \
  --install ash_graphql,ash_postgres --install ash_admin --yes

Expected Behavior

No compilation errors should occur

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    Someday

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions