Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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

  1. 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 as 1.0.0):
[dependencies]
gates = "1.0.0"

Using a relaxed micro version of a dependency

  1. 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 as 1.0) to accept any micro version number:
[dependencies]
gates = "1.0"

Using a relaxed minor version of a dependency

  1. 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 as 1) to accept any minor and any micro version number:
[dependencies]
gates = "1"

Overriding the location of a dependency

  1. 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

  1. 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

  1. 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.