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

Using ash.gen.resource fails if dev config file conditionally import another file using if ..., do: ... #214

Open
smt116 opened this issue Feb 3, 2025 · 7 comments
Labels
bug Something isn't working

Comments

@smt116
Copy link

smt116 commented Feb 3, 2025

Describe the bug

eden λ mix ash.gen.resource Eden.Vendor.Brand --uuid-primary-key id

Issues:

* lib/eden/vendor/brand.ex: Igniter would have produced invalid syntax.

This is almost certainly a bug in Igniter, or in the implementation
of the task/function you are using.

** (ArgumentError) invalid or duplicate keys for if, only "do" and an optional "else" are permitted
    (elixir 1.18.2) lib/kernel.ex:3924: Kernel.build_if/2
    (elixir 1.18.2) expanding macro: Kernel.if/2
    config/config.exs:190: (file)


* lib/eden/vendor.ex: Igniter would have produced invalid syntax.

This is almost certainly a bug in Igniter, or in the implementation
of the task/function you are using.

** (ArgumentError) invalid or duplicate keys for if, only "do" and an optional "else" are permitted
    (elixir 1.18.2) lib/kernel.ex:3924: Kernel.build_if/2
    (elixir 1.18.2) expanding macro: Kernel.if/2
    config/config.exs:189: (file)


* lib/eden/vendor.ex: Igniter would have produced invalid syntax.

This is almost certainly a bug in Igniter, or in the implementation
of the task/function you are using.

** (ArgumentError) invalid or duplicate keys for if, only "do" and an optional "else" are permitted
    (elixir 1.18.2) lib/kernel.ex:3924: Kernel.build_if/2
    (elixir 1.18.2) expanding macro: Kernel.if/2
    config/config.exs:190: (file)


* config/config.exs: Igniter would have produced invalid syntax.

This is almost certainly a bug in Igniter, or in the implementation
of the task/function you are using.
...

To Reproduce

Use

if __DIR__ |> Path.join("dev.secret.exs") |> File.exists?(), do: import_config("dev.secret.exs")

in your config/dev.exs file. Changing it to:

if __DIR__ |> Path.join("dev.secret.exs") |> File.exists?() do
  import_config("dev.secret.exs")
end

fixes the problem.

Expected behavior
Support both if formats.

Runtime
Elixir 1.18.2

Dependency              Current  Latest  Status
ash                     3.4.62   3.4.62  Up-to-date
ash_json_api            1.4.18   1.4.18  Up-to-date
ash_phoenix             2.1.17   2.1.17  Up-to-date
ash_postgres            2.5.1    2.5.1   Up-to-date
bandit                  1.6.7    1.6.7   Up-to-date
credo                   1.7.11   1.7.11  Up-to-date
dialyxir                1.4.5    1.4.5   Up-to-date
dns_cluster             0.1.3    0.1.3   Up-to-date
ecto_sql                3.12.1   3.12.1  Up-to-date
esbuild                 0.8.2    0.8.2   Up-to-date
finch                   0.19.0   0.19.0  Up-to-date
floki                   0.37.0   0.37.0  Up-to-date
gettext                 0.26.2   0.26.2  Up-to-date
igniter                 0.5.20   0.5.20  Up-to-date
jason                   1.4.4    1.4.4   Up-to-date
mix_audit               2.1.4    2.1.4   Up-to-date
phoenix                 1.7.19   1.7.19  Up-to-date
phoenix_ecto            4.6.3    4.6.3   Up-to-date
phoenix_html            4.2.0    4.2.0   Up-to-date
phoenix_live_dashboard  0.8.6    0.8.6   Up-to-date
phoenix_live_reload     1.5.3    1.5.3   Up-to-date
phoenix_live_view       1.0.3    1.0.3   Up-to-date
postgrex                0.19.3   0.19.3  Up-to-date
sobelow                 0.13.0   0.13.0  Up-to-date
sourceror               1.7.1    1.7.1   Up-to-date
swoosh                  1.17.9   1.17.9  Up-to-date
tailwind                0.2.4    0.2.4   Up-to-date
telemetry_metrics       1.1.0    1.1.0   Up-to-date
telemetry_poller        1.1.0    1.1.0   Up-to-date

Additional context
https://discord.com/channels/711271361523351632/1253324141491261472/1335948526357839933

@smt116 smt116 added the bug Something isn't working label Feb 3, 2025
@zachdaniel
Copy link
Contributor

Hmm....this is strange. I can't reproduce as easily as I thought I'd be able to. It may be some kind of interaction between other config in that file.

@zachdaniel zachdaniel transferred this issue from ash-project/ash Feb 3, 2025
@zachdaniel
Copy link
Contributor

Is it possible to share the full configuration? Or maybe anything else about the config file that stands out to you as strange?

@zachdaniel
Copy link
Contributor

actually I think I may know what's up 😄

@smt116
Copy link
Author

smt116 commented Feb 3, 2025

Basically, this is a config that has been generated from ... --install ash,ash_phoenix,ash_postgres --with phx.new command. The only thing I've added was that "if dev secret exists, then pull it in".

@zachdaniel
Copy link
Contributor

👍 perfect, thanks

@zachdaniel
Copy link
Contributor

Got it reproduced 👍

@zachdaniel
Copy link
Contributor

Fixed in 0.5.21

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