casey / just

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

Importing many times the same justfile. #2436

Open gl-yziquel opened 5 days ago

gl-yziquel commented 5 days ago

Hi.

I am writing some multiple just fragments to handle some aspects of my build systems. Some of them, say A.just and B.just depend on another, C.just. Essentially, I'd like to write import "A.just" and/or import "B.just". When I import only one of them, it works fine: A.just is importing C.just, or B.just is importing C.just. No conflict. When I import both of them, the tasks in C.just conflict as they are declared twice, once for each import.

Ideally, there should be some "caching" mechanism that would allow the C.just file to be detected to be the same, and thus imported only once. No ?

casey commented 5 days ago

Thanks for opening an issue! You should be able to do set allow-duplicate-recipes, which will cause duplicate recipes to not be an error.

I'm going to leave this open though, since I think possibly we should just detect this and avoid throwing an error in the first place. If you're importing the same recipe from the same file, then there's really no problem with allowing it, since the two recipes are identical.

gl-yziquel commented 5 days ago

Thanks for opening an issue! You should be able to do set allow-duplicate-recipes, which will cause duplicate recipes to not be an error.

In fact, that's what I'd like to avoid doing. This case (when the import is the same file) should, IMO, not be handled with an "override" mechanism like "set allow-duplicate-recipes" (which is what, by the way, I am currently doing to work around this issue). The reason being that I'd like, precisely, to bail out when genuine duplicate recipes appear.

In essence, I am turning off a safety mechanism to solve an issue that, IMO, should not exist in the first place.

(But there is no hurry: I can live with the "set allow-duplicate-recipes" workaround.)