`allow-duplicate-recipes`: first-imported wins for duplicates across imports, contradicting docs
## Summary
With `set allow-duplicate-recipes`, when two imported justfiles define a recipe with the same name, the **first-imported** definition wins, not the last-imported. The docs say:
> Allow recipes appearing later in a justfile to override earlier recipes with the same name.
This is true for definitions inside a single file, but the opposite holds for cross-import duplicates.
## Reproduction
```bash
mkdir -p /tmp/just-bug && cd /tmp/just-bug
cat > a.just <<'INNER_EOF'
greet:
echo "from a"
INNER_EOF
cat > b.just <<'INNER_EOF'
greet:
echo "from b"
INNER_EOF
cat > justfile <<'INNER_EOF'
set allow-duplicate-recipes
import "./a.just"
import "./b.just"
INNER_EOF
just --show greet
just greet
```
### Actual
```
greet:
echo "from a"
echo "from a"
from a
```
### Expected
`b.just` is imported later, so per the docs it should override `a.just`:
```
greet:
echo "from b"
from b
```
## Notes
- A direct definition in the root justfile correctly beats both imports — only the cross-import case is surprising.
- This silently broke a recipe override in our codebase: the local override defined in a file imported *after* the upstream one was dead code, and CI deploys behaved as if it didn't exist. We only noticed because one definition lacked `*args` forwarding while the other had it.
- Either the docs should clarify the precedence rule (last *direct* definition wins; first-imported wins for duplicates from imports), or the resolution should be made consistent (last-imported wins, matching textual order).
## Environment
- `just --version`: 1.50.0
- OS: macOS Tahoe v26.4.1
- Shell: zsh
0 条评论