dojo
dojo copied to clipboard
[BUG] Dojo metadata not detected for projects with indirect dependencies
Describe the bug
The dojo_metadata_from_package function in crates/dojo-world/src/metadata.rs fails to detect Dojo dependencies for projects that indirectly depend on Dojo through other packages. This causes issues with projects like application project that use Dojo indirectly through dependencies such as protocol that uses dojo.
The current implementation only checks for direct dependencies on dojo or dojo_plugin, missing indirect dependencies and returning default metadata for projects that should have Dojo metadata.
To Reproduce
Steps to reproduce the behavior:
- Clone the repo pixelaw/app_template
- run
sozo print-envand this just return default value (onlyRPC URL: http://localhost:5050/) - Add
dojo = { git = "https://github.com/dojoengine/dojo", tag = "v1.0.0-alpha.11" }toScarb.tomlexplicitly - re-run
sozo print-env, and it output correct metadata
Expected behavior
The dojo_metadata_from_package function should recursively check for Dojo dependencies in all direct and indirect dependencies of a package. It should correctly identify and process Dojo metadata for projects with indirect Dojo dependencies.
Screenshots
None
Additional context
Here, this condition just look at the dependency section in Scarb.toml so can't detect indirect dependency right now.
https://github.com/dojoengine/dojo/blob/069bc1af6c071f10185c758615f80e631938a741/crates/dojo-world/src/metadata.rs#L75-L84
Proposed solutions:
-
Use
Scarb.lockinstead ofScarb.tomlfor dependency resolution:- This would allow us to see all transitive dependencies, including indirect ones.
- Implementation would involve parsing the
Scarb.lockfile and checking for anydojo-related packages.
-
Require explicit declaration of Dojo dependency:
- Even for projects that use Dojo indirectly, require them to explicitly declare the Dojo dependency in their
Scarb.toml. - This would simplify dependency detection but might be less convenient for users.
- Even for projects that use Dojo indirectly, require them to explicitly declare the Dojo dependency in their