Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple use of the same import is detected as circular #1848

Closed
Tracked by #929
pprkut opened this issue Jan 15, 2024 · 1 comment · Fixed by #2065
Closed
Tracked by #929

Multiple use of the same import is detected as circular #1848

pprkut opened this issue Jan 15, 2024 · 1 comment · Fixed by #2065

Comments

@pprkut
Copy link

pprkut commented Jan 15, 2024

Currently circular imports are defined as including each other. This is the test verifying that behavior:

fn circular_import() {
  Test::new()
    .justfile("import 'a'")
    .tree(tree! {
      a: "import 'b'",
      b: "import 'a'",
    })
    .status(EXIT_FAILURE)
    .stderr_regex(path_for_regex(
      "error: Import `.*/a` in `.*/b` is circular\n",
    ))
    .run();
}

However, multiple use of the same import is also detected as circular and I don't think that is correct (test passes, but shouldn't IMHO):

fn reused_import() {
  Test::new()
    .justfile(
      "
      import 'a'
      import 'b'
    ",
    )
    .tree(tree! {
      a: "import 'c'",
      b: "import 'c'",
      c: "",
    })
    .status(EXIT_FAILURE)
    .stderr_regex(path_for_regex(
      "error: Import `.*/c` in `.*/a` is circular\n",
    ))
    .run();
}
@vlaci
Copy link

vlaci commented Feb 13, 2024

Also ran into this: my use case is to have a common.just containing recipes meaningful in all submodules, so it made sense to me to create the following structure:

.
├─ mod-a
│   └── justfile
├─ mod-b
│   └── justfile
├── common.just
└── justfile
# ./justfile
import "common.just"
mod mod-a
mod mod-b
...
# mod-{a,b}/justfile
import "../common.just"
...
# common.just

# Prints this help
help:
    @just --list --unsorted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants