{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/cargo/issues/2385","repository_url":"https://api.github.com/repos/rust-lang/cargo","labels_url":"https://api.github.com/repos/rust-lang/cargo/issues/2385/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/cargo/issues/2385/comments","events_url":"https://api.github.com/repos/rust-lang/cargo/issues/2385/events","html_url":"https://github.com/rust-lang/cargo/pull/2385","id":133366938,"number":2385,"title":"Implement top-level overrides","user":{"login":"alexcrichton","id":64996,"avatar_url":"https://avatars.githubusercontent.com/u/64996?v=3","gravatar_id":"","url":"https://api.github.com/users/alexcrichton","html_url":"https://github.com/alexcrichton","followers_url":"https://api.github.com/users/alexcrichton/followers","following_url":"https://api.github.com/users/alexcrichton/following{/other_user}","gists_url":"https://api.github.com/users/alexcrichton/gists{/gist_id}","starred_url":"https://api.github.com/users/alexcrichton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexcrichton/subscriptions","organizations_url":"https://api.github.com/users/alexcrichton/orgs","repos_url":"https://api.github.com/users/alexcrichton/repos","events_url":"https://api.github.com/users/alexcrichton/events{/privacy}","received_events_url":"https://api.github.com/users/alexcrichton/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":{"login":"wycats","id":4,"avatar_url":"https://avatars.githubusercontent.com/u/4?v=3","gravatar_id":"","url":"https://api.github.com/users/wycats","html_url":"https://github.com/wycats","followers_url":"https://api.github.com/users/wycats/followers","following_url":"https://api.github.com/users/wycats/following{/other_user}","gists_url":"https://api.github.com/users/wycats/gists{/gist_id}","starred_url":"https://api.github.com/users/wycats/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wycats/subscriptions","organizations_url":"https://api.github.com/users/wycats/orgs","repos_url":"https://api.github.com/users/wycats/repos","events_url":"https://api.github.com/users/wycats/events{/privacy}","received_events_url":"https://api.github.com/users/wycats/received_events","type":"User","site_admin":false},"milestone":null,"comments":49,"created_at":"2016-02-12T23:17:01Z","updated_at":"2016-04-15T23:19:51Z","closed_at":"2016-04-07T21:50:47Z","pull_request":{"url":"https://api.github.com/repos/rust-lang/cargo/pulls/2385","html_url":"https://github.com/rust-lang/cargo/pull/2385","diff_url":"https://github.com/rust-lang/cargo/pull/2385.diff","patch_url":"https://github.com/rust-lang/cargo/pull/2385.patch"},"body":"This commit is an implementation of top-level overrides to be encoded into the\r\nmanifest itself directly. This style of override is distinct from the existing\r\n`paths` support in `.cargo/config` in two important ways:\r\n\r\n* Top level overrides are intended to be checked in and shared amongst all\r\n  developers of a project.\r\n* Top level overrides are reflected in `Cargo.lock`.\r\n\r\nThe second point is crucially important here as it will ensure that an override\r\non one machine behaves the same as an override on another machine. This solves\r\nmany long-standing problems with `paths`-based overrides which suffer from some\r\nlevel of nondeterminism as they're not encoded.\r\n\r\nFrom a syntactical point of view, an override looks like:\r\n\r\n```toml\r\n[replace]\r\n\"libc:0.2.0\" = { git = 'https://github.com/my-username/libc';, branch = '0.2-fork' }\r\n```\r\n\r\nThis declaration indicates that whenever resolution would otherwise encounter\r\nthe `libc` package version 0.2.0 from crates.io, it should instead replace it\r\nwith the custom git dependency on a specific branch.\r\n\r\nThe key \"libc:0.2.0\" here is actually a package id specification which will\r\nallow selecting various components of a graph. For example the same named\r\npackage coming from two distinct locations can be selected against, as well as\r\nmultiple versions of one crate in a dependency graph. The replacement dependency\r\nhas the same syntax as the `[dependencies]` section of Cargo.toml.\r\n\r\nOne of the major uses of this syntax will be, for example, using a temporary\r\nfork of a crate while the changes are pushed upstream to the original repo. This\r\nwill avoid the need to change the intermediate projects immediately, and over\r\ntime once fixes have landed upstream the `[replace]` section in a `Cargo.toml`\r\ncan be removed.\r\n\r\nThere are also two crucial restrictions on overrides.\r\n\r\n* A crate with the name `foo` can only get overridden with packages also of\r\n  the name `foo`.\r\n* A crate can only get overridden with a crate of the exact same version.\r\n\r\nA consequence of these restrictions is that crates.io cannot be used to replace\r\nanything from crates.io. There's only one version of something on crates.io, so\r\nthere's nothing else to replace it with (name/version are a unique key).\r\n\r\nCloses #942"},"comment":{"url":"https://api.github.com/repos/rust-lang/cargo/issues/comments/210681172","html_url":"https://github.com/rust-lang/cargo/pull/2385#issuecomment-210681172","issue_url":"https://api.github.com/repos/rust-lang/cargo/issues/2385","id":210681172,"user":{"login":"alexcrichton","id":64996,"avatar_url":"https://avatars.githubusercontent.com/u/64996?v=3","gravatar_id":"","url":"https://api.github.com/users/alexcrichton","html_url":"https://github.com/alexcrichton","followers_url":"https://api.github.com/users/alexcrichton/followers","following_url":"https://api.github.com/users/alexcrichton/following{/other_user}","gists_url":"https://api.github.com/users/alexcrichton/gists{/gist_id}","starred_url":"https://api.github.com/users/alexcrichton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexcrichton/subscriptions","organizations_url":"https://api.github.com/users/alexcrichton/orgs","repos_url":"https://api.github.com/users/alexcrichton/repos","events_url":"https://api.github.com/users/alexcrichton/events{/privacy}","received_events_url":"https://api.github.com/users/alexcrichton/received_events","type":"User","site_admin":false},"created_at":"2016-04-15T23:19:51Z","updated_at":"2016-04-15T23:19:51Z","body":"@jmesmon I was mostly just responding to your comment about \"trying to force people's work flows\" by pointing out that Cargo is itself a workflow tool.\r\n\r\nIn general, yes, you're indeed right! Cargo shouldn't be preventing use cases and should be a general tool for all. That doesn't mean, however, that literally every feature should be added to Cargo. For example to work around the restriction of the same version you just need to fork a repo and change the version backwards. The idea is that it's a step up from the normal workflow, not forbidden."}}