Search code examples
rustrust-cargo

How to tell Cargo to use a git repository as source for an indirect dependency instead of crates.io?


A few days ago, cross-compiling to JavaScript via Emscripten has finally hit nightly. I wanted to compile a project using glium in that manner. However, there are still many Emscripten-related bugs in many crates. While maintainers usually fix those bugs quickly, they don't necessarily release those bug fixes to crates.io immediately.

In my case, glium depends on glutin. glutin had a bug which is fixed now, but only in the git repository, not on crates.io. Note: glutin is not a direct dependency of my project; only an indirect one through glium!

How do I tell Cargo to use the glutin repository as source for glutin instead of crates.io?


Solution

  • You can use the [patch] section in your project's Cargo.toml. For more information, check out the documentation.

    [patch.crates-io]
    glutin = { git = 'https://github.com/tomaka/glutin' }