casey / just

🤖 Just a command runner
https://just.systems
Creative Commons Zero v1.0 Universal
22.48k stars 491 forks source link

Dependency from a parent/child justfile #1550

Open dhruvkb opened 1 year ago

dhruvkb commented 1 year ago

My project has the following directory structure:

a
├── b
│   └── justfile
│       └── rec_b → rec_a
└── justfile
    └── rec_a

The inner justfile contains a recipe, rec_b, that depends on a recipe in the outer justfile, rec_a.

To show this dependency, I tried the following but none of them work:

rec_b: rec_a
# error: Recipe `rec_b` has unknown dependency `rec_a`

rec_b: ../rec_a
# error: Unknown start of token

From the shell I can access recipes in the parent justfile with .. so is this not supported inside the justfile syntax?

[a/b/]$ just ../rec_a # works
dhruvkb commented 1 year ago

I just realised that the opposite is also true, justfiles cannot identify dependencies in a child justfile.

a
├── b
│   └── justfile
│       ├── rec_b → rec_a
│       └── rec_c
└── justfile
    ├── rec_a
    └── rec_d → rec_c

In such a setup rec_d cannot refer to and depend on rec_c defined in the inner justfile.

rec_d: b/rec_c
# error: Expected '&&', comment, end of file, end of line, identifier, or '(', but found '/'