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

Intermittent Rewrite.SourceError during app creation #170

Open
brunoripa opened this issue Dec 20, 2024 · 6 comments
Open

Intermittent Rewrite.SourceError during app creation #170

brunoripa opened this issue Dec 20, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@brunoripa
Copy link

Describe the bug

I am creating a new Phoenix app and it fails with the following message:

* ash.codegen add_authentication_resources

Proceed with changes? [y/n] y

This command is successfully executed, and then I try to execute `mix igniter.new test_app --install ash,ash_authentication_phoenix --with phx.new`

Issues:

* ** (Rewrite.SourceError) could not write to file "lib/test_app/application.ex": file changed since reading

To Reproduce

I installed Igniter by executing mix archive.install hex igniter_new which installed version 0.5

The next command is mix igniter.new test_app --install ash,ash_authentication_phoenix --with phx.new, which frequently ends up with the reported error.

Expected behavior

A successful app creation, ready to get started

** Runtime

  • Elixir version
Erlang/OTP 27 [erts-15.2] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1] [jit:ns]

Elixir 1.17.3 (compiled with Erlang/OTP 27)
  • Erlang version
Erlang/OTP 27 [erts-15.2] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1] [jit:ns]

Eshell V15.2 (press Ctrl+G to abort, type help(). for help)
  • OS
Edition	Windows 11 Home
Version	22H2
Installed on	‎8/‎19/‎2022
OS build	22621.4387
Experience	Windows Feature Experience Pack 1000.22700.1047.0
  • Igniter version

0.5.0

  • any related extension versions

Additional context

The same command happens to work every now and then, making me think about some sort or race condition.

@brunoripa brunoripa added the bug Something isn't working label Dec 20, 2024
@zachdaniel
Copy link
Contributor

Hmm... I wonder if this may be OS specific to do with how we check if a file has been modified. Do you have access to a linux or Mac machine to try this on? I can't reproduce.

@brunoripa
Copy link
Author

Yes, I should be able to give this a go on Mac and Linux, I'll just need some time. I'll update the ticket asap. Thanks @zachdaniel

@brunoripa
Copy link
Author

I just tried on Linux Mint:

Linux mint 6.8.0-47-generic #47-Ubuntu SMP PREEMPT_DYNAMIC Fri Sep 27 21:40:26 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

it worked nicely.

@brunoripa
Copy link
Author

@zachdaniel, I confirm that I have the same issue in MacOS.

Elixir: 1.16.2
Erlang: OTP 26

Machine: Apple M2 (any other info needed) ?

@brunoripa
Copy link
Author

brunoripa commented Dec 22, 2024

Also the file causing the failure is somehow different, I have seen application.ex, repo.ex, and others, random mostly. And sometimes I see a specular error:

Issues:

* Required lib/test_app2/application.ex but it did not exist

So not a problem about a file being changed, but about a file not being there.

@zachdaniel
Copy link
Contributor

@hrzndhrn can you think of a reason this might happen on windows? As far as I can tell this is coming from our call to Rewrite.write_all. Perhaps file timestamps are less reliable on windows?

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