Skip to content

Submodules: Fix readme and issue 2824 #2829

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

Merged
merged 6 commits into from
Jul 19, 2025
Merged

Conversation

eisbaw
Copy link
Contributor

@eisbaw eisbaw commented Jul 18, 2025

See commit messages for details.

This fixes issue #2824

eisbaw added 2 commits July 18, 2025 23:31
Add comprehensive documentation for cross-module dependencies using
the :: syntax. This feature already works but was not documented,
leading users to think it didn't exist (issue casey#2252).

- Expand introduction section with working examples
- Add Cross-Module Dependencies subsection to Dependencies section
- Add Cross-Module Dependencies subsection to Modules section
- Remove outdated claim that modules can't depend on each other
- Show multiple dependencies and mixed local+module dependencies
Bug: When executing cross-module dependencies like
"parent: submodule::recipe", the dependency recipe was executed with
the root module's ExecutionContext instead of the submodule's context.
This caused submodule recipes to run in the wrong working directory.

Root cause: The dependency execution logic in run_dependencies() used
the same ExecutionContext for all dependencies regardless of which
module they belonged to.

Solution: Added create_dependency_context() method that:
1. Analyzes recipe namepaths to detect cross-module dependencies
2. Navigates module hierarchy to find the correct submodule
3. Creates new ExecutionContext with proper submodule reference
4. Ensures dependencies execute in their correct module context

This fixes both normal module recipes (now run in submodule directory)
and [no-cd] module recipes (now run in invocation directory as intended)

Add comprehensive tests to verify the working directory fix for
cross-module dependencies:

- cross_module_dependency_runs_in_submodule_directory: Tests that normal
  cross-module dependencies execute in the correct submodule directory
- cross_module_dependency_with_no_cd_runs_in_invocation_directory: Tests
  that [no-cd] cross-module dependencies execute in the invocation
  directory
- nested_cross_module_dependency_runs_in_correct_directory: Tests that
  deeply nested module dependencies work correctly

These tests verify that the fix properly resolves the module working
directory bug where cross-module dependencies were executing with the
wrong ExecutionContext.
@casey
Copy link
Owner

casey commented Jul 19, 2025

Thanks for this PR!

I'm not sure about the readme changes, so I reverted them.

I also didn't like the approach of passing in an execution context at the top level. Instead, I re-used the scope dictionary to also store a reference to the justfile, and retrieve it when we retrieve the scope, and build the correct execution context at that point.

@casey casey enabled auto-merge (squash) July 19, 2025 02:35
@casey casey merged commit b96aba9 into casey:master Jul 19, 2025
6 checks passed
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 this pull request may close these issues.

2 participants