Repository navigation
Closed
Description
# mix.exs
defmodule LfeTest.MixProject do
use Mix.Project
def project do
[
app: :lfe_test,
version: "0.1.0",
elixir: "~> 1.15",
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
[
# {:dep_from_hexpm, "~> 0.3.0"},
# {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"}
{:lfe, "2.1.3"}
]
end
end
> elixir --version
Erlang/OTP 26 [erts-14.1.1] [source] [64-bit] [smp:10:10] [ds:10:10:10] [async-threads:1] [jit]
Elixir 1.15.7 (compiled with Erlang/OTP 24)
> mix deps.get
Resolving Hex dependencies...
Resolution completed in 0.009s
New:
lfe 2.1.3
* Getting lfe (Hex package)
> mix compile
===> Analyzing applications...
===> Compiling lfe
src/cl.lfe: error writing file
===> Hook for app_compile failed!
** (Mix) Could not compile dependency :lfe, "/Users/simonelnahas/.asdf/installs/elixir/1.15/.mix/elixir/1-15/rebar3 bare compile --paths /Users/simonelnahas/Documents/Developer/lfe_test/_build/dev/lib/*/ebin" command failed. Errors may have been logged above. You can recompile this dependency with "mix deps.compile lfe --force", update it with "mix deps.update lfe" or clean it with "mix deps.clean lfe"
> rebar3 lfe repl
===> Verifying dependencies...
Erlang/OTP 26 [erts-14.1.1] [source] [64-bit] [smp:10:10] [ds:10:10:10] [async-threads:1] [jit]
..-~.~_~---..
( \\ ) | A Lisp-2+ on the Erlang VM
|`-.._/_\\_.-': | Type (help) for usage info.
| g |_ \ |
| n | | | Docs: http://docs.lfe.io/
| a / / | Source: http://github.com/lfe/lfe
\ l |_/ |
\ r / | LFE v2.1.2 (abort with ^C; enter JCL with ^G)
`-E___.-'
lfe>
Reacted by lin72h
Metadata
Metadata
Assignees
Labels
No labels
Activity
simonelnahas commentedon May 15, 2024
Running on MacOS 1.14.1
simonelnahas commentedon May 23, 2024
Upgrading to LFE 2.1.4, didn't make a difference.
oubiwann commentedon Aug 3, 2024
My first guess is that this is a problem with the LFE mix plugin? Have you filed a ticket there or chatted with the dev?
If that guess is correct, I wonder if the plugin (or config?) needs some help with ordering ... LFE's Erlang files need to be compiled before the supporting libs (clj.lfe and cl.lfe) can be compiled ... I would need to see full build debug logs to determine if this second guess is correct.
We accomplish this in the LFE project with the explicit ordering of our
maketargets (see https://github.com/lfe/lfe/blob/develop/Makefile, if you read GNU make).The LFE rebar3 plugin has this in its "DNA" as it were ... it always compiles the Erlang files before compiling the LFE files.
diasbruno commentedon Nov 3, 2025
It seems to be the problem.
Elixir 1.18.4
Erlang/OTP 27
LFE 2.2.0
diasbruno commentedon Nov 3, 2025
iprog4u commentedon Nov 3, 2025
oubiwann commentedon Nov 3, 2025
@diasbruno do you know if Mix has a directive like rebar.config does for "first files"? Or if it reads rebar.config files at all? I have several projects where I need to add a couple of entries for files that need to be compile first ...
diasbruno commentedon Nov 3, 2025
From what I debugged, it seems that it is trying to write the file in a path that was not created.
Before writing the file, I added the
filelib:ensure_dir(Name), and it compile ok.The question is that in don't know who must be responsible to create the building path.
oubiwann commentedon Nov 4, 2025
I'm pretty confused :-( I'm seeing too many different things and I don't have a clear picture of what's going on:
Also, LFE itself ensures it has everything it needs to build via the Makefile. We also added a secondary build route using rebar3 for rebar3 projects that pull in LFE as a dependency ... but it's very minimal: basically pre-hooks that tie into the standard LFE build route (Makefile). There is a rebar config script for defining Erlang version specific operations (again, a convenience). But note that there is nothing rebar3 plugin specific in LFE -- all of that has to be provided by the rebar3_lfe plugin (using all the compile hooks, the rest of the rebar3 API, etc.).
To cut my rambling short, this really feels like it should either be a ticket in the lfe mix repo, or a ticket in the rebar3_lfe repo ...
That being said, we can still keep discussing here until everything is clear :-) Questions I need answers to in order to better help:
diasbruno commentedon Nov 4, 2025
@iprog4u Thanks. I was look at the repo and it uses the old
lfe-compile. But I did found that it has an implementation ofensure_dir.diasbruno commentedon Nov 4, 2025
Ok. Let's get a step back...
I've updated the repo https://github.com/diasbruno/lfe_test using the
mix_lfe(it's a bit behind, but I'll try to patch it).Now, rebar3_lfe is failing to compile.
oubiwann commentedon Nov 4, 2025
Got it! Thanks for your patience ... reading though the sources now.
oubiwann commentedon Nov 4, 2025
Okay, I've installed Elixir and have run through the steps. It actually looks like it's compiling the LFE *.erl files before compiling the .lfe files. And it looks like it's using LFE's rebar.config.
0.5.4 seems to be working for me ... did you delete the
_builddir? (or at least the rebar3_lfe plugin in it?).Still poking ...
diasbruno commentedon Nov 4, 2025
A fresh build from the repo.
oubiwann commentedon Nov 4, 2025
Sorry, I should have been more specific about my comment "rebar3_lfe 0.5.4 works for me" ... what I meant was that rebar3_lfe 0.5.4 downloaded and compiled without issue, and I didn't see the same error you saw with this:
I can confirm that even with rebar3_lfe 0.5.4, the LFE does not compile in this Elixir project.
Oh, wow -- did you see this?
In particular:
I think what might be going on is that
mixcompiles rebar3 dependencies usingrebar3 bare compileinstead ofrebar3 compile. Thebare compileprovider doesn't execute build hooks in the same way - specifically, the hooks that create theebindirectory and compile.lfesources aren't being invoked (or aren't being invoked properly?).oubiwann commentedon Nov 4, 2025
There's another fundamental issues here: using another tools instead of providing native support in the mix tool introduces another level of tricky dependency management and bug chasing. I think the "real" solution is to actually create a mix compiler plugin for LFE.
I'm looking into that now ...
oubiwann commentedon Nov 4, 2025
Well, crap. The problem is that any time a rebar3-based LFE project is pulled in as a dep, mix is going to have to use its rebar3 wrapper ... and it's going to compile with
rebar3 bare compile.oubiwann commentedon Nov 4, 2025
I'm going to try an experiment ... see if I can get mix to not use rebar3_lfe for LFE projects 🤞
oubiwann commentedon Nov 4, 2025
Okay, I've got some success ... check out this branch:
CI/CD is passing for it, as are local builds. I haven't tried to use it in the test project yet ... ran out of time tonight.
oubiwann commentedon Nov 4, 2025
Had some time to come back to this before bed tonight, and I did manage to get it "working" ... but this is very rough 😬
Here's what I changed the
mix.esfile to:And here are the commands I used:
This completely circumvents rebar3 for LFE code in a mix project ... but there are pitfalls:
This was so painful and rough, that I'm not convinced this is a better path anymore 😢
I feel like there's got to be a way to get mix to use
rebar3 compileinstead ofrebar3 bare compile... but I'm pretty toasty at this point (I like my tools to be more flexible than this 🤷).oubiwann commentedon Nov 4, 2025
Feel free to work on a fork of the release/0.4.x branch ... if you get some stuff working, we can iterate on a PR.
oubiwann commentedon Nov 4, 2025
I have an idea which might let us get around the mix issues of calling
rebar3 bare compile... (and userebar3 compileinstead)oubiwann commentedon Nov 4, 2025
Ugh. So much catch-22. Mix actually does support a way to override the
reabr3 bare compileand that's essentially just overriding how mix compiles a library (and maybe that lib's deps?) with the:compileoption (used in the same line of a mix.es file as the dep is declared).However: LFE projects will still fail the
ebin/<proj>.appcheck that mix performs, since LFE projects use rebar3's support forsrc/<proj>.app.src(this is one of the things that the above mix tasklfe.bootstrapdoes).More "however": I'm pretty sure that by not using
bare compile, projects would compile using the standard rebar3_builddirs ... which would result in something like_build/dev/lib/ltest/_build/default/lib/ltest. That, of course, is broken. And probably whybare compileeven exists ...There are a couple of routes we can explore before reimplementing rebar3's compile and dependency logic in an LFE mix plugin:
rebar3 compileto fully build LFE projects in mix_build/*), maybe also override rebar3 defaults with a new profile likeelixir_buildin itsrebar.config, and finally uses the:compileoverride in the mix.es dep to call this build scriptAnd, if those all fail, the ultimate fallback of reimplementing chunks of rebar3's logic in mix tasks, etc., would be the path forward ...