Specifying Dependencies
Your projects can depend on other projects found in the catalog or subdirectories on your local file system. You can also temporarily override the location of a dependency - for example, to be able to test out a bug fix in the dependency that you are working on locally. You can also have dependencies that are only used during development. This section walks through the different ways you can specify the dependencies of a project.
Assumptions
The guides in this section assume you are running commands from the root directory or any subdirectory of the current project. The current project is the project being actively developed.
Guides
- Using a strict version of a dependency
- Using a relaxed micro version of a dependency
- Using a relaxed minor version of a dependency
- Overriding the location of a dependency
- Including a dependency only for development
- Differentiating among dependencies of the same name
Using a strict version of a dependency
- Add the name of the external project (such as
gates
) as a new entry in the[dependencies]
table of the current project's manifest with the fully qualified version to use (such as1.0.0
):
[dependencies]
gates = "1.0.0"
Using a relaxed micro version of a dependency
- Add the name of the external project (such as
gates
) as a new entry in the[dependencies]
table of the current project's manifest with a partially qualified version to use, omitting the micro version number (such as1.0
) to accept any micro version number:
[dependencies]
gates = "1.0"
Using a relaxed minor version of a dependency
- Add the name of the external project (such as
gates
) as a new entry in the[dependencies]
table of the current project's manifest with a partially qualified version to use, omitting the minor and micro version number (such as1
) to accept any minor and any micro version number:
[dependencies]
gates = "1"
Overriding the location of a dependency
- Specify the local file sytem path to the root directory of the external project using the
path
field to use it as the source for the dependency:
[dependencies]
gates = { path = "../gates", version = "1.0.1-dev" }
Note that the version
field is required and its value must match the version
defined in the local dependency's manifest file.
Including a dependency only for development
- Add the name of the external project (such as
gates
) as a new entry in the[dev-dependencies]
table of the current project's manifest:
[dev-dependencies]
gates = "1.0.0"
Tip: All methods of specifying dependencies using the
[dependencies]
table can also be applied to the[dev-dependencies]
table.
Differentiating among dependencies of the same name
- Specify the UUID of the external project that has a conflicting name in the catalog using the
uuid
field to explicitly request this project as the dependency:
[dependencies]
gates = { uuid = "3p3oajkuoukigs45fskr0svnv", version = "1.0.0" }
Note that the version
field is required.