nix2intel

nix2intel OP

what if I were to tell you that it was a space in the name with a certain length? When I do

sh <(curl 'https://ash-hq.org/new/hairbnb?install=phoenix') \
    && cd hairbnb \
      && mix igniter.install \
    ash_phoenix ash_json_api ash_postgres ash_authentication \
    ash_authentication_phoenix ash_admin ash_state_machine \
    ash_paper_trail cloak ash_cloak \
    --auth-strategy password \
      --yes

The above works, but the below will fail.

sh <(curl 'https://ash-hq.org/new/some_long_name_with_spaces?install=phoenix') \
    && cd some_long_name_with_spaces \
      && mix igniter.install \
    ash_phoenix ash_json_api ash_postgres ash_authentication \
    ash_authentication_phoenix ash_admin ash_state_machine ash_paper_trail cloak \
    ash_cloak \
    --auth-strategy password \
      --yes

I get the error that

Issues:

  • ** (Rewrite.SourceError) could not write to file “lib/some_long_name_with_spaces/application.ex”: file changed since reading

i’ll pull that down, connect, and get you a copy of that debug.

0
Post #31
nix2intel

nix2intel OP

here is the pastebin for the one that gives an issue

0
Post #32
nix2intel

nix2intel OP

here was the debug_state function I called:

defp debug_state(label, igniter, extra \\ nil) do
    IO.puts("\n=== DEBUG: #{label} ===")

    sources = igniter.rewrite.sources
    IO.puts("Sources count: #{map_size(sources)}")

    if extra do
      IO.puts("\nExtra Info:")
      IO.inspect(extra, label: "Extra data", pretty: true)
    end

    Enum.each(sources, fn {path, source} ->
      IO.puts("\nSource: #{path}")
      IO.inspect(source.hash, label: "Hash")

      try do
        v1 = Rewrite.Source.get(source, :content, 1)
        current = Rewrite.Source.get(source, :content)
        IO.puts("Has v1?: #{v1 != nil}")
        IO.puts("Has current?: #{current != nil}")

        if v1 && current do
          IO.puts("Changed?: #{v1 != current}")
        end
      rescue
        _ -> IO.puts("Error accessing content")
      end
    end)

    IO.puts("=== End #{label} ===\n")
    # Important: return the igniter
    igniter
  end
0
Post #33
zachdaniel

zachdaniel

Creator of Ash

YESSSS you did it! Thank you :heart: The “other OSes” problem was a total red herring. I can reproduce with a long name :fire: Thank you so much.

1
Post #34
nix2intel

nix2intel OP

When you find out why im dying to know lol

1
Post #35
zachdaniel

zachdaniel

Creator of Ash

will definitely report back

0
Post #36
zachdaniel

zachdaniel

Creator of Ash

Wowee, that was a rabbit hole :laughing: Fixed versions are released. Here is what was happening:

Duplicate files were being added into the rewrite struct, due to how in some places (when adding a glob), we were adding files by absolute path, instead of relative to CWD path.

The kicker is how we were alerted to this problem :sweat: The reason that it only happened when the app name was longer is because rewrite uses Task.async_stream to write files in parallel. Inside of that stream each thing reads its original contents and then writes it if it hasn’t changed. The slight additional extra time that it took to either read the file or hash the file name (not sure which) for the longer file names, changed the performance of the writing enough that one of the tasks was slow enough to see the new file contents from one of the other tasks completing and writing its file contents. Now there are no duplicates because everything is using relative paths.

This could also have been the source of other subtle bugs :sob:

Thank you for your help in figuring this one out!

4
Post #37
— All posts loaded —