When duplicate recipes are in the same module, the later one overrides the earlier one:
set allow-duplicate-recipes
foo:
foo:
echo winner
When they are in imports, because just uses a stack to process imports, the duplicate in the earlier module will win, because it will be processed last:
# a.just
foo:
echo winner
# b.just
foo:
# justfile
import 'a.just'
import 'b.just'
This was discovered by @redsun82 in #2523.
This is not great behavior, and pretty clearly a bug. I'm not sure, but I don't think we ever considered this case when designing either imports or allow-duplicate-recipes. (@neunenak do you have any recollection of this? I'm thinking that we just didn't notice it.)
just has a very strong backwards compatibility guarantee, but this is definitely a bug and should probably be fixed.
However, I feel like there are probably a bunch of existing justfiles that rely on this behavior, and they're likely especially complicated, so such a bug fix could be disruptive.
The most non-disruptive way to fix it would be:
- Add a setting which opts into the new behavior
- Print a warning if a justfile doesn't opt in to the new behavior and doing so would change which recipes are defined
- Elevate the warning in 2 to an error
- After some suitably long period of time, change the default to the new behavior, and make the setting a no-op
We could also add a setting which opts into the new behavior, and then wait and see if it's worth actually changing the default behavior.
When duplicate recipes are in the same module, the later one overrides the earlier one:
When they are in imports, because
justuses a stack to process imports, the duplicate in the earlier module will win, because it will be processed last:This was discovered by @redsun82 in #2523.
This is not great behavior, and pretty clearly a bug. I'm not sure, but I don't think we ever considered this case when designing either imports or
allow-duplicate-recipes. (@neunenak do you have any recollection of this? I'm thinking that we just didn't notice it.)justhas a very strong backwards compatibility guarantee, but this is definitely a bug and should probably be fixed.However, I feel like there are probably a bunch of existing
justfilesthat rely on this behavior, and they're likely especially complicated, so such a bug fix could be disruptive.The most non-disruptive way to fix it would be:
We could also add a setting which opts into the new behavior, and then wait and see if it's worth actually changing the default behavior.