Sinc

Sinc

Compile problem for peg in project with slime and conform

I’m updating a project from Elixir 1.13 to Elixir 1.14. I have dependencies on both slime and conform. Both these projects use the peg compiler, and this is creating a problem. If it caused it on 1.13 I didn’t notice. The problem is that both mix files invoke the peg compiler on tasks/compile.peg.exs. Both files define Mix.Tasks.Compile.Peg. With the 1.14 compiler when I do a deps.compile it will compile slime first and conform second, and conform errors because it appears to be reusing the Compile.Peg file compiled for slime. I don’t see a way around this in a deps.compile. It seems to resolve itself if I just do a mix compile.

I played around in conform for a while. I tried changing the file name, the module name, and some other things, and it seems like the peg compiler is fairly fixated on using those names.

The error is:

could not compile dependency :conform, "mix compile" failed. Errors may have been logged above. You can recompile this dependency with "mix deps.compile conform", update it with "mix deps.update conform" or clean it with "mix deps.clean conform"
** (File.Error) could not read file "src/slime_parser.peg.eex": no such file or directory
    (elixir 1.14.5) lib/file.ex:358: File.read!/1
    (eex 1.14.5) lib/eex.ex:259: EEx.compile_file/2
    (eex 1.14.5) lib/eex.ex:300: EEx.eval_file/3
    /var/lib/ucxbuild/infinity_one/deps/slime/tasks/compile.peg.exs:15: Mix.Tasks.Compile.Peg.run/1
    (mix 1.14.5) lib/mix/task.ex:421: anonymous fn/3 in Mix.Task.run_task/4
    (mix 1.14.5) lib/mix/tasks/compile.all.ex:92: Mix.Tasks.Compile.All.run_compiler/2
    (mix 1.14.5) lib/mix/tasks/compile.all.ex:72: Mix.Tasks.Compile.All.compile/4
    (mix 1.14.5) lib/mix/tasks/compile.all.ex:59: Mix.Tasks.Compile.All.with_logger_app/2

Note that although this is the conform compile it is trying to execute deps/slime/tasks/compile.peg.exs:15: Mix.Tasks.Compile.run/1.

Looking down the stack trace (1.14.5-otp-25) it looks like this problem might come from Mix.Task.run_task, which despite compiling conform, finds the Compile.Peg module in the slime directory.

Is this something I can fix in the mix files for either slime or conform by cleaning the Peg module after/before compiling so that the two don’t mix, or should this be the responsibility of the compiler to find the right module?

This duplicates with a really simple new project, using the following mix.exs:

defmodule CompilePeg.MixProject do
  use Mix.Project

  def project do
    [
      app: :compile_peg,
      version: "0.1.0",
      elixir: "~> 1.14",
      start_permanent: Mix.env() == :prod,
      deps: deps()
    ]
  end

  # Run "mix help compile.app" to learn about applications.
  def application do
    [
      extra_applications: [:logger]
    ]
  end

  # Run "mix help deps" to learn about dependencies.
  defp deps do
    [
      {:slime, "~> 1.0"},
      {:conform, github: "infinityoneframework/conform"}
      # {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"}
    ]
  end
end

With 1.13.3-otp-24 I get a single warning, which actually makes me think that the order of the output might be a little off, but the output looks like this:

mix deps.compile
WARN:  Missing plugins: [rebar3_hex]
==> neotoma (compile)
Compiled src/neotoma.erl
Compiled src/neotoma_parse.erl
Compiling src/conform_parse.peg
PEG manifest updated
==> conform
Compiling 1 file (.erl)
Compiling 20 files (.ex)
Generated conform app
warning: redefining module Mix.Tasks.Compile.Peg (current version defined in memory)
  /var/src/compile_peg/deps/slime/tasks/compile.peg.exs:1

'/var/src/compile_peg/deps/slime/src/slime_parser_transform.erl' already exists, skipping generation.
==> slime
Compiling 2 files (.erl)
Compiling 11 files (.ex)
Generated slime app

(The part that seems odd is that the warning about recompiling the Peg module is printed about the path in slime, even though the compiler hasn’t yet printed the slime name. Is the name printed after some of the work is already done (or queued while the errors are output directly)?)

Is this a compiler problem (likely yes since it didn’t happen with the 1.13 compiler), and/or is there a workaround that I might be able to add in one of the projects?

First Post!

Sinc

Sinc

I worked around this by changing the mix.exs for conform so that it won’t actually run the PEG compiler under normal circumstances. Since the PEG files aren’t likely to change the app just won’t dynamically check for updates. When we change OTP releases where the generated code might change we’ll check for differences.

This still seems to be a compiler problem wiht the Mix.Task, so if someone wants to try duplicating it with the mix.exs deps above you’ll have to set your mix.lock to:
"conform": {:git, "https://github.com/infinityoneframework/conform.git", "222117c8885ea58d5e9e5d14bc161a192c1452a2", []},
The current file on master has the workaround.

Where Next?

Popular in Questions Top

aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
marius95
Hello everyone, I try to use an Javascript Event Handler in my root.html.leex file. Therefore I created a function in the app.js file: ...
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
mgjohns61585
Could someone help me? I’m making my first elixir program, number guessing game. I can’t figure out how to convert the user’s guess from ...
New
shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
nobody
How to bind a phoenix app to a specific ip address? could not find anything about that, nowhere, unfortunately, but for me this is quite...
New
LegitStack
I’m trying to make a websocket server in Phoenix or raw Elixir. I heard about gun, I think I could use cowboy, but since I’m not that sma...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New

Other popular topics Top

TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
274 41539 114
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 30877 112
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 43622 214
New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
boundedvariable
I am going through the kafka architecture. All the features what the kafka is providing are already in Erlang. I would like hear your opi...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New

We're in Beta

About us Mission Statement