Cargo sub-project dependencies

I was working on the ncollide project (after a fresh git clone) and noticed that it has several subfolder cargo projects which the main project has as dependencies. The problem is that because cargo has subproject dependencies like "ncollide_pipepline" defined as ncollide_pipeline = "*", it always reads the project as seen on the master branch (and ignores my local changes). I have to manually set each dependency such as ncollide_pipline = { path="/path/to/local/dir/" } for it to read my local code changes to that project subfolder. It seems to me that cargo should be looking in the project subfolders for any Cargo.toml whose package name matches the dependency first and then look in the repository only if it was not found.

This seems problematic because I would not want to accidentally commit a local path by accident. It also requires me to modify the project every time I want to modify it locally. Am I using cargo wrong or does this seem like a bug?

1 Like

I think this is ncollide not using cargo to its fullest abilities, I suspect it is using dependencies there to allow publishing the top level crate to, but it is actually fine to publish a project with path dependencies to They will be rewritten to the appropriate dependency crate.

That is, switching them all to dependencies like ncollide_pipeline = { path = "ncollide_pipeline", version = "0.4" } should work essentially exactly like the existing code (the additional version field is necessary for publishing it).

1 Like