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

Spark generates very long module names causing compile errors on some systems #103

Open
jimsynz opened this issue Jun 22, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@jimsynz
Copy link
Contributor

jimsynz commented Jun 22, 2024

Describe the bug
Deeply nested DSLs create module names such as Elixir.Wayfarer.Dsl.Wayfarer.Config.Wayfarer.Targets.Targets.Wayfarer.Targets.Targets.Http.Wayfarer.Targets.Targets.HealthChecks.HealthChecks which will trigger enametoolong on some systems:

08:20:24.969 [error] Process #PID<0.153.0> raised an exception
** (File.Error) could not write to file "/home/james/Dev/harton.dev/james/wayfarer/_build/dev/lib/wayfarer/ebin/Elixir.Wayfarer.Dsl.Wayfarer.Config.Wayfarer.Targets.Targets.Wayfarer.Targets.Targets.Http.Wayfarer.Targets.Targets.HealthChecks.HealthChecks.beam": file name too long
    (elixir 1.17.1) lib/file.ex:1144: File.write!/3
    (elixir 1.17.1) lib/kernel/parallel_compiler.ex:334: anonymous fn/3 in Kernel.ParallelCompiler.write_module_binaries/3
    (elixir 1.17.1) lib/enum.ex:1268: anonymous fn/3 in Enum.flat_map/2
    (stdlib 6.0) maps.erl:860: :maps.fold_1/4
    (elixir 1.17.1) lib/enum.ex:2543: Enum.flat_map/2
    (elixir 1.17.1) lib/kernel/parallel_compiler.ex:261: Kernel.ParallelCompiler.spawn_workers/3
    (mix 1.17.1) lib/mix/compilers/elixir.ex:1018: anonymous fn/9 in Mix.Compilers.Elixir.compiler_loop/6

To be clear this an issue with BEAM and not Spark or Elixir and in response to a similar bug report against Elixir José's response boils down to "just use shorter module names". I think he's right. There are a couple of strategies I can think of;

  1. Move generated modules out of the Elixir. namespace (I suggest Spark.).
  2. Name modules by using a hash of their DSL path. I'd suggest :erlang.phash2 since it should always be available. It doesn't really matter if the modules are "discoverable" as they're only ever imported by Spark anyway. We can always add a flag to disable this behaviour while debugging.

To Reproduce
I triggered it by using eCryptfs on a portable Linux device because the effective file length limit is ~140 bytes. It is possible to reproduce on Linux & macOS (255 byte limit) by creating a DSL with very long entity names.

Expected behavior
The DSL extension should cleanly compile.

Runtime

  • Elixir version 1.17.1
  • Erlang version 27.0
  • OS Linux 5.10.17-v8+ aarch64. Raspberry Pi OS based on Debian 11 (bullseye).
  • Spark version 2.2.4
  • any related extension versions

Additional context
Add any other context about the problem here.

@jimsynz jimsynz added the bug Something isn't working label Jun 22, 2024
@zachdaniel
Copy link
Contributor

Open to any of these. The generated modules are hidden and any public use of them is incorrect. So honestly I'm down for "anything that works" 😅

@zachdaniel
Copy link
Contributor

@jimsynz if you've got some time to tackle this that would be great, got a lot on ye olde plate at the moment.

@jimsynz
Copy link
Contributor Author

jimsynz commented Jun 23, 2024

Yeah, I've added it to my list :)

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