casey / just

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

Bug: when recipe repeats recipe inside it, it only runs the first time #1985

Closed whyboris closed 4 months ago

whyboris commented 7 months ago

Example justfile:

lol: hi hello hi

@hi:
  echo "1"

@hello:
  echo "2"

Expected output from just lol

1
2
1

Actual output from just lol

1
2

I think this is a bug because I had a command that did cleanup between various other commands and I spent 2 hours trying to figure out why cleanup wasn't working 😢

casey commented 7 months ago

This is actually as intended, although I can see why it would be confusing. Just will only run normal recipes once, even if they appear more than once on the command line, or more than once in recipe dependencies. Just also doesn't necessarily run recipes in the same order as they're passed on the command line. If you do just a b, and a is a dependency of b, it will run b first and then a.

whyboris commented 7 months ago

I suggest adding a quick note in the relevant section:

https://github.com/casey/just?tab=readme-ov-file#features

You can also use dependencies to run multiple recipes by default:

_Note:_ just will not run a recipe twice

The model I had in my head was "recipe", meaning a step-by-step instruction of what just will do. I'm puzzled why anyone would expect just to ignore an instruction.

I am not insisting on implementing changes - I super ❤️ love just ❤️ -- I just think that even though my use case is unusual, there may be others who will have cleanup steps in their script.

My example: https://github.com/whyboris/utilitarianism.net/blob/main/justfile I build a website in three steps: search, PDF, and production - so I had to duplicate a cleanup step :trollface:

casey commented 7 months ago

I think that's reasonable, I'll reopen this issue to track adding a note to the docs.

colemannerd commented 5 months ago

@casey I think this issue is now closed.