Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when installing with Igniter - Igniter.Project.Application.app_name/0 is undefined #362

Open
sevenseacat opened this issue Jul 25, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@sevenseacat
Copy link
Contributor

sevenseacat commented Jul 25, 2024

Describe the bug
I've set up a new Phoenix app to test out Igniter setup, and run into an issue with AshPostgres.

==> phoenix_ecto
Compiling 7 files (.ex)
** (UndefinedFunctionError) function Igniter.Project.Application.app_name/0 is undefined (module Igniter.Project.Application is not available)
    (igniter 0.3.9) Igniter.Project.Application.app_name()
    (ash_postgres 2.1.15) lib/mix/tasks/ash_postgres.install.ex:10: Mix.Tasks.AshPostgres.Install.igniter/2
    (elixir 1.17.2) lib/enum.ex:2531: Enum."-reduce/3-lists^foldl/2-0-"/3
    (igniter 0.3.9) lib/igniter/util/install.ex:101: Igniter.Util.Install.run_installers/5

Upon re-running ash_postgres.install, the error does not appear, and everything works as normal?

To Reproduce

  • Generate a new Phoenix app (using mix phx.new) - generates a 1.7.14 app
  • Install Igniter (latest version is 0.3.9)
  • Run mix igniter.install ash (installs 3.2.6)
  • Run mix igniter.install ash_postgres (installs 2.1.15)

The library installs successfully, but the error occurs when it runs ash_postgres.install.

Expected behavior

ash_postgres.install should run successfully and patch my repo etc. files.

** Runtime

  • Elixir version 1.17.2-otp-27
  • Erlang version 27.0.1
  • OS macOS Sonoma
  • Ash version 3.2.6
  • Igniter version 0.3.9
  • AshPostgres version 2.1.15
@sevenseacat sevenseacat added bug Something isn't working needs review labels Jul 25, 2024
@sevenseacat
Copy link
Contributor Author

Hm, it seemed possible because I've been mucking around with Igniter for a while, but mix archive only shows hex 2.1.1 and phx_new 1.7.14. Just replicated it on my other laptop :(

@sevenseacat
Copy link
Contributor Author

sevenseacat commented Jul 25, 2024

So I searched all asdf-installed Elixir versions for any installed Igniter archives, and found two:

/Users/rebecca/.asdf/installs/elixir/1.15.7-otp-26
hex-2.1.1/         igniter_new-0.2.3/ phx_new-1.7.14/

/Users/rebecca/.asdf/installs/elixir/1.17.0-otp-27
hex-2.1.1/         igniter_new-0.2.3/

(note: I've been testing this with Elixir 1.17.2-otp-27)

Deleted the two archives and re-ran the test and it worked :( So not a bug in Igniter or AshPostgres, but what?

@zachdaniel
Copy link
Contributor

This is definitely very strange, and I feel like there is some kind of pattern around this. I dont' see why the igniter_new archive would have anything to do with it. But two people who know what they are doing having this issue in quick succession indicates some kind of problem. Will keep an eye out.

@sevenseacat
Copy link
Contributor Author

sevenseacat commented Jul 26, 2024

Just for funsies, I've gotten almost-identical problems again on $work_laptop when attempting to install both AshGraphql and AshJsonApi.

For AshGraphql, it prompts to add :ash_graphql to mix.exs, I confirm, it compiles everything, then the error occurs:

==> phoenix_ecto
Compiling 7 files (.ex)
Generated phoenix_ecto app
** (UndefinedFunctionError) function Igniter.Project.Formatter.import_dep/2 is undefined 
(module Igniter.Project.Formatter is not available)
    (igniter 0.3.9) Igniter.Project.Formatter.import_dep(%Igniter{rewrite: %Rewrite{sources: 
%{".formatter.exs" => %Rewrite.Source{from: :file, path: ".formatter.exs", content: "[\n  
import_deps: [:ash_postgres, :ash, :ecto, :ecto_sql, :phoenix],\n  subdirectories: [\"priv/*/
migrations\"],\n  plugins: [Spark.Formatter, Phoenix.LiveView.HTMLFormatter],\n  inputs: 
[\"*.{heex,ex,exs}\", \"{config,lib,test}/**/*.{heex,ex,exs}\", \"priv/*/seeds.exs\"]\n]\n", 
hash: <<76, 178, 39, 224, 31, 232, 124, 20, 141, 144, 125, 168, 78, 59, 186, 85>>, owner: 
Rewrite, filetype: %Rewrite.Source.Ex{quoted: {:__block__, [trailing_comments: [], 
leading_comments: [], end_of_expression: [newlines: 1, line: 6, column: 2], newlines: 1, 
closing: [line: 6, column: 1], line: 1, column: 1], [[{{:__block__, [trailing_comments: [], 
leading_comments: [], format: :keyword, line: 2, column: 3], [:import_deps]}, {:__block__, 
[trailing_comments: [], leading_comments: [], closing: [line: 2, column: 64],...
...
__, ...}}, {{:__block__, ...}, {...}}, {{...}, ...}, {...}, ...]]}}]]}]}}]]}, formatter: 
#Function<4.125904074/2 in Rewrite.Source.Ex.formatter/2>, opts: []}, history: [], issues: 
[], private: %{}}}, extensions: %{".ex" => Rewrite.Source.Ex, ".exs" => Rewrite.Source.Ex, 
"default" => Rewrite.Source}}, issues: [], tasks: [], warnings: [], assigns: %{igniter_exs: 
[]}, moves: %{}}, :ash_graphql)
    (ash_graphql 1.2.1) lib/mix/tasks/ash_graphql.install.ex:10: Mix.Tasks.AshGraphql.Install.igniter/2
    (elixir 1.17.2) lib/enum.ex:2531: Enum."-reduce/3-lists^foldl/2-0-"/3
    (igniter 0.3.9) lib/igniter/util/install.ex:101: Igniter.Util.Install.run_installers/5
    (mix 1.17.2) lib/mix/task.ex:495: anonymous fn/3 in Mix.Task.run_task/5
    (mix 1.17.2) lib/mix/cli.ex:96: Mix.CLI.run_task/2
    /Users/rebecca/.asdf/installs/elixir/1.17.2-otp-27/bin/mix:2: (file)

Same thing with AshJsonApi, but a different error:

==> phoenix_ecto
Compiling 7 files (.ex)
** (UndefinedFunctionError) function Igniter.Libs.Phoenix.web_module_name/1 is undefined 
(module Igniter.Libs.Phoenix is not available)
    (igniter 0.3.9) Igniter.Libs.Phoenix.web_module_name("AshJsonApiRouter")
    (ash_json_api 1.3.8) lib/mix/tasks/ash_json_api.install.ex:14: Mix.Tasks.AshJsonApi.Install.igniter/2
    (elixir 1.17.2) lib/enum.ex:2531: Enum."-reduce/3-lists^foldl/2-0-"/3
    (igniter 0.3.9) lib/igniter/util/install.ex:101: Igniter.Util.Install.run_installers/5
    (mix 1.17.2) lib/mix/task.ex:495: anonymous fn/3 in Mix.Task.run_task/5
    (mix 1.17.2) lib/mix/cli.ex:96: Mix.CLI.run_task/2
    /Users/rebecca/.asdf/installs/elixir/1.17.2-otp-27/bin/mix:2: (file)

This machine has no installed Igniter archives. I have a whole lot of Elixir versions installed, all have hex-2.x.x, some have phx_new-1.7.x, but no Igniter at all.

Re-running the installs works fine for both of them. It doesn't compile anything (I guess compilation finished the first time I ran it?), just jumps straight to the results of running the package installer.

I tried deleting ~/.hex/cache.ets and reran the setup after deleting deps/ash_(package) and _build/dev/lib/ash_(package), and it still failed.

Something weird is going on.

@zachdaniel zachdaniel reopened this Jul 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants