dojo icon indicating copy to clipboard operation
dojo copied to clipboard

[BUG] Dojo metadata not detected for projects with indirect dependencies

Open posaune0423 opened this issue 1 year ago • 4 comments
trafficstars

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:

  1. Clone the repo pixelaw/app_template
  2. run sozo print-env and this just return default value (only RPC URL: http://localhost:5050/)
  3. Add dojo = { git = "https://github.com/dojoengine/dojo", tag = "v1.0.0-alpha.11" } to Scarb.toml explicitly
  4. 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:

  1. Use Scarb.lock instead of Scarb.toml for dependency resolution:

    • This would allow us to see all transitive dependencies, including indirect ones.
    • Implementation would involve parsing the Scarb.lock file and checking for any dojo-related packages.
  2. 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.

posaune0423 avatar Sep 15 '24 21:09 posaune0423