How to link against a local Rust library? (similar to npm link)

When developing a library in node, if you wish to develop against a library that only exists locally, before you npm publish, you can use npm link /path/to/other/node_library.

What is the equivalent of this for Rust? How do you create another a foo executable that links to bar library, without pushing bar library to a git remote first?

The official rust tutorial shows how to do this using raw rustc, how can this be done in Cargo.toml?

(The cargo documentation shows you how to build a lib, but now how to link to one that doesn't have a remote repository.)

It is also possible to use git file: URL if your dependency is in a local git repo:

[dependencies.local_dep]
git = "file:/some/local/path"

There is also a very useful feature when you want to use your own local copy of some package. You can specify a path to such package in ~/.cargo/config file:

package-name = "/path/to/package"

With this configuration when some other package (let's name it a) requires package-name, regardless of what is declared in a manifest about package-name location, package-name will be build from the source tree specified in this config file. This is useful when you need to test your changes in a library which other projects depend on.

You can do:

[dependencies.local_dep]
path = "some/local/path"

Check out https://github.com/gfx-rs/gfx-rs/blob/master/Cargo.toml for an example.