Repository: casey/just (rust)

Issue:
Can't access env vars defined in Justfile from submodule
It seems that version 1.42 introduced a change https://github.com/casey/just/pull/2810 that does not allow submodules to access env variables defined in the main Justfile. 

`Justfile`
```
mod test './test.justfile'

export a := "a"
```

`test.justfile`
```
test:
    echo $a
```

Running `just test` fails because a is unbound variable.

Pull request description:
Export variables to submodules
Fixes #2812.

Patch:
diff --git a/src/justfile.rs b/src/justfile.rs
index 50a4354b..f0b26d65 100644
--- a/src/justfile.rs
+++ b/src/justfile.rs
@@ -91,7 +91,7 @@ impl<'src> Justfile<'src> {
         config,
         dotenv,
         &BTreeMap::new(),
-        root,
+        scope,
         scopes,
         search,
       )?;


Test patch:
diff --git a/tests/modules.rs b/tests/modules.rs
index b27ee592..6075aa77 100644
--- a/tests/modules.rs
+++ b/tests/modules.rs
@@ -1018,3 +1018,54 @@ fn overrides_work_when_submodule_is_present() {
     .stdout("b\n")
     .run();
 }
+
+#[test]
+fn exported_variables_are_available_in_submodules() {
+  Test::new()
+    .write("foo.just", "bar:\n @echo $x")
+    .justfile(
+      "
+        mod foo
+
+        export x := 'a'
+      ",
+    )
+    .test_round_trip(false)
+    .arg("foo::bar")
+    .stdout("a\n")
+    .run();
+}
+
+#[test]
+fn exported_variables_can_be_unexported_in_submodules() {
+  Test::new()
+    .write("foo.just", "unexport x\nbar:\n @echo ${x:-default}")
+    .justfile(
+      "
+        mod foo
+
+        export x := 'a'
+      ",
+    )
+    .test_round_trip(false)
+    .arg("foo::bar")
+    .stdout("default\n")
+    .run();
+}
+
+#[test]
+fn exported_variables_can_be_overridden_in_submodules() {
+  Test::new()
+    .write("foo.just", "export x := 'b'\nbar:\n @echo $x")
+    .justfile(
+      "
+        mod foo
+
+        export x := 'a'
+      ",
+    )
+    .test_round_trip(false)
+    .arg("foo::bar")
+    .stdout("b\n")
+    .run();
+}