rebar3 icon indicating copy to clipboard operation
rebar3 copied to clipboard

Include filename collision between app and dep fails build

Open lrascao opened this issue 4 years ago • 7 comments

git clone https://github.com/lrascao/rebar3_include_bug_app && cd rebar3_include_bug_app && rebar3 compile

===> Compiling _build/default/lib/dep/src/dep_app.erl failed
_build/default/lib/dep/src/dep_app.erl:15: undefined macro 'SOME_DEFINE'

_build/default/lib/dep/src/dep_app.erl:12: function start/2 undefined

While compiling dep rebar3 finds one of it's includes in app and goes with that.

lrascao avatar Aug 22 '19 21:08 lrascao

Is it the same if you don't have include/ in the path like it currently does in the dep? Either way it is a bug but I'm curious.

tsloughter avatar Aug 22 '19 21:08 tsloughter

If you take out include/ from the path it works

lrascao avatar Aug 22 '19 21:08 lrascao

the issue seems to be related with the current working directory that rebar3 sets when invoking compile:file, it doesn't change it to the dep so compile finds the .hrl in the app and not the dep

lrascao avatar Aug 22 '19 21:08 lrascao

Yeah, I can confirm the thing. It does look like that because the compiler looks for . as a first path, everything blows up. Working around this means we'd need to change the directory for every single module we build to use the app's working directory to avoid this clash.

I see no way around it. The fix isn't super complex, so I made a prototype of it in https://github.com/erlang/rebar3/pull/2156

ferd avatar Sep 01 '19 23:09 ferd

The fix I tried seems not to work. I have a feeling we're stuck with this bug unless the compiler is re-worked to just call erlc at some point. The Erlang compiler really does not like being called from a top-level module at this point. I don't know.

It seems the more we go towards "not changing directories because it blows everything up", we just find different ways for everything to blow up.

ferd avatar Sep 01 '19 23:09 ferd

It might make sense to only mention things that have changed, so that we don't get one notification per ticket that is not yet fixed and does not need to change state.

This specific issue is something we can't really fix at all because the issue is with how the Erlang compiler itself resolves paths always starting with . and stuff there always taking precedence.

ferd avatar Sep 15 '20 12:09 ferd

It might make sense to only mention things that have changed

Sure, sorry about that. It was late in the evening and early in the morning. I removed all other similar comments from all other changed Issues.

paulo-ferraz-oliveira avatar Sep 15 '20 14:09 paulo-ferraz-oliveira