Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow config to specify dependency overrides as git links #1481

Closed
hugoduncan opened this issue Apr 4, 2015 · 15 comments
Closed

Allow config to specify dependency overrides as git links #1481

hugoduncan opened this issue Apr 4, 2015 · 15 comments
Labels
A-crate-dependencies Area: [dependencies] of any kind A-overrides Area: general issues with overriding dependencies (patch, replace, paths)

Comments

@hugoduncan
Copy link
Contributor

When working on nightly, it is sometimes expedient to use a crate that has been updated but not yet pushed to crates.io. Being able to specify the git link for the crate as an override would avoid having to edit Cargo.toml.

This would also be useful when wanting to try a project using a pull request from a depency's repository.

@steveklabnik
Copy link
Member

You already can, and I would say using git with overrides is the primary use case. Can you post more details maybe?

@alexcrichton
Copy link
Member

Yes using path overrides should cover this use case, but did that not suffice for you?

@hugoduncan
Copy link
Contributor Author

Path overrides are great, but require you to locally clone the repository in question. What I was looking for was a mechanism to directly specify a git link for the override, rather than a local path. Cloning the repo locally isn't particularly difficult, but it does make your build then depend on local paths. I'm trying to write some commit hooks that can test a local project on commit, and it would simplify things if the local project didn't have path dependencies (outside of the project tree).

@steveklabnik
Copy link
Member

@hugoduncan in the link Alex posted, it shows using a git link.

@hugoduncan
Copy link
Contributor Author

@steveklabnik iiuc, that link shows using a git link in Cargo.toml, rather than in a .cargo/config.

In .cargo/config I would like to be able to specify a git link to override the [dependencies] information in Cargo.toml.

The .cargo/config might have an identical format to the Cargo.toml:

# .cargo/config
[dependencies.conduit]
git = "https://github.com/conduit-rust/conduit.git"

This would override the dependency for conduit in Cargo.toml, in whatever form it was specified there (path, git link or version spec).

@steveklabnik
Copy link
Member

So, I went and tried it, and I just literally thought that it worked but it doesn't.

So I guess consider that a huge 👍 from me.

@alexcrichton
Copy link
Member

Hm I suppose I don't personally see too much difference in editing Cargo.toml vs adding a line to a configuration file, for example you could have:

#conduit = "0.7.0"
conduit = { git = "https://github.com/conduit-rust/conduit" }

Could you elaborate a little more on why you want to specifically avoid editing Cargo.toml?

@hugoduncan
Copy link
Contributor Author

Cargo.toml is under version control, while .cargo/config isn't. Not editing Cargo.toml just helps prevent committing transient versions of Cargo.toml, and makes it easy to check for local modifications by checking for the presence of .cargo/config rather than having to open and inspect Cargo.toml. Not a huge difference.

The paths item in .cargo/config is equally redundant, as that can also be achieved by editing Cargo.toml.

Apologies for multiple notifications - I managed to accidentally delete my previous reply.

@hugoduncan
Copy link
Contributor Author

I've now tried using Cargo.toml directly to override versions, but this doesn't work for overriding transitive dependencies. eg. in a project that uses serde, adding the following to Cargo.toml results in both the specifed version, and the version specified in serde's own Cargo.toml to be used:

[dependencies.aster]
#git = "https://github.com/erickt/rust-aster.git"
git = "https://github.com/Byron/rust-aster.git"
rev = "23eae95b675e340788012fbeb46a1af80daa1623"

@alexcrichton
Copy link
Member

Ah yes I tend to often forget the subtle difference, but .cargo/config is different as it will transitively override everything, not just for the local project.

I'm not sure I'm totally sold on this feature yet as we'd in theory need an override syntax for all forms of dependencies at that point (e.g. crates.io deps, path deps, SVN deps eventually, etc). Sticking to just paths doesn't really seem like it's that much overhead as a clone isn't really too hard to do.

@hugoduncan
Copy link
Contributor Author

A clone isn't particularly hard to do. However, I'm trying to write some build automation based on using (docker) containers, and it does add to the complexity of that automation.

@alexcrichton
Copy link
Member

Well in some sense the complexity has to live somewhere :)

@codyps
Copy link
Contributor

codyps commented Jun 9, 2015

I'm also looking for a commit-able way to override package sources, see sfackler/rust-postgres#130 for an example of something that I could have easily resolved with it.

@maurer
Copy link

maurer commented Oct 21, 2015

I'm running into something like this as well. Using a git override in the Cargo.toml causes problems for me because I depend on A, and on B, and B depends on A. Overriding A leads to a program which will not compile because B now builds against a different A than the one that I've depended on. Overriding at a global level, as per paths, is what I want to do, but I can't really commit something in this form.

(Specifically, I build against capnp and capnp-rpc. I had a PR merged for capnp that I want to use for development. Right now, I need to instruct anyone trying to build it to clone master capnp, and edit paths to point at it.)

@carols10cents carols10cents added A-overrides Area: general issues with overriding dependencies (patch, replace, paths) A-crate-dependencies Area: [dependencies] of any kind labels May 11, 2017
@weihanglo
Copy link
Member

Cargo supports [patch] in Cargo configuration since 1.56. This should cover use cases mentioned above.

As this is an old issue and dependency overriding has evolved since then, I am going to close this. If it is wrong or your scenario is yet covered, please file a new issue. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-crate-dependencies Area: [dependencies] of any kind A-overrides Area: general issues with overriding dependencies (patch, replace, paths)
Projects
None yet
Development

No branches or pull requests

7 participants