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

JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
sergio
In Ruby, I can go: User.find_by(email: "foobar@email.com").update(email: "hello@email.com") How can I do something similar in Elixir? ...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
tduccuong
Hi, is there any work on GUI with Elixir, that is similar to Electron/Javascript? My idea is to bundle Phoenix and BEAM into a single se...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
chensan
I have a User schema with a :from_id field set to type :string: defmodule TweetBot.Repo.Migrations.CreateUsers do use Ecto.Migration ...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
idi527
I’ve been re-reading swift book again and noticed that multiline strings there don’t have a trailing line break, unlike in elixir iex(2)...
New

Other popular topics Top

pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 record...
New
_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
chrismccord
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
Nvim
Elixir appears to be a superior language to Python. I don’t see any advantage of Python over Elixir. Are there any?
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

We're in Beta

About us Mission Statement