Closed jnicholls closed 9 years ago
You can actually do this today! When you depend on a git repository Cargo will crawl the entire repo looking for packages and you can depend on any of them.
Oh ok, awesome! I thought it failed the first time I tried it, but I'll give it another shot. Thanks.
Fantastic! This worked like a charm.
I tried this and it worked, but it gives me the following warning:
warning: dependency (ethcore-transaction) specification is ambiguous. Only one of `git` or `path` is allowed. This will be considered an error in future versions
I am using the following dependency:
ethcore-transaction = { git = "https://github.com/paritytech/parity-ethereum", path = "ethcore/transaction", branch = "master" }
With the following cargo version:
cargo 1.31.0 (339d9f9c8 2018-11-16)
Is it safe to keep this?
@augustoteixeira you'll want to remove either git
or path
there, this'll become a hard error eventually
There is a huge git repo, from which I need a single folder (with its own cargo file and src folder).
What is the proper way to handle that?
Unfortunately git has no way to check out only one folder, so there's nothing to do there unfortunately.
I see. So when I was doing this:
subfolder = { git = "url_for_the_big_repo", path = "subfolder" }
which leads to the warning. Cargo was just doing the same as if I had typed this?
subfolder = { git = "url_for_the_big_repo" }
Correct!
Today I face the same issue, I was needing a sub folder inside a git repo. I think this should be implemented
Isn't crawling the whole git repo dangerous? What happens if two different subfolders contain crates with equal name? Will that be reported? I would certainly favor allowing explicit subfolders with a combination of git = "....." path="....."
What's the status of this? I'd like to use a git repo subfolder too
Definitely need this feature. I encountered this today:
What happens if two different subfolders contain crates with equal name?
Not only the issue of name clashes, but there's a performance cost to crawling a huge repo when the client can be told exactly where to look.
isn't crawling the whole git repo dangerous? What happens if two different subfolders contain crates with equal name? Will that be reported? I would certainly favor allowing explicit subfolders with a combination of git = "....." path="....."
I need it too, thanks google bring me here.
There's an issue that can occur when there is a submodule inside of a repository, how do you explicitly depend on both the main folder and the sub-module without using path
? Cargo automatically pulls the sub-module path into depends but the compiler doesn't like that.
Currently for one of my projects I have to do this to get cargo to properly pull the right versions and rust to compile:
[dependencies]
twitch_api2 = {git = "https://github.com/Emilgardis/twitch_api2", tag="v0.6.0-rc.1", features=["all"]}
twitch_oauth2 = { git = "https://github.com/Emilgardis/twitch_api2", tag="v0.6.0-rc.1", path="twitch_oauth2", features=["all"]}
Without this second line the compiler complains it can't find the crate, am I missing something?
Compiling twitch_oauth2 v0.5.2 (https://github.com/Emilgardis/twitch_api2?tag=v0.6.0-rc.1#3b5f82ec)
Compiling twitch_api2 v0.6.0-rc.1 (https://github.com/Emilgardis/twitch_api2?tag=v0.6.0-rc.1#3b5f82ec)
Compiling twitch-dmenu v0.1.0 (/home/weaton/git/twitch-dmenu)
error[E0463]: can't find crate for `twitch_oauth2`
--> src/main.rs:7:1
|
7 | extern crate twitch_oauth2;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate
Still an issue especially when the submodules you dont want are hundreds of megabytes.
Yes, you are mistaken. If it is not working, please open a new issue with a minimal repoducabe example.
Sorry... I resolved my issue and deleted the earlier post.
Hello, I am trying to load a subfolder in git as a dependency by doing this
config = { git = "https://github.com/foundry-rs/foundry", path = "crates" }
But I get the following error! @jnicholls Can you help me please?
error: failed to load manifest for workspace member `/Users/tilakmadichetti/Documents/OpenSource/realaderyn/aderyn`
Caused by:
failed to load manifest for dependency `aderyn_driver`
Caused by:
failed to parse manifest at `/Users/tilakmadichetti/Documents/OpenSource/realaderyn/aderyn_driver/Cargo.toml`
Caused by:
dependency (config) specification is ambiguous. Only one of `git` or `path` is allowed.
For
dependencies
we can havegit = <url>
orpath = <path>
but we cannot combine the two, in the cases where a cargo package lives somewhere nested inside of a git repo, i.e. not in the root of the repo. It would be very powerful to be able to provide a relative path into a git repo.Use case: A repo that is a client library containing bindings in more than one language, and the Rust binding is under the
rust
folder inside that repo.The workaround today is to submodule the repo into your own repo, and use a relative
path
config. This levies the requirement of using git of course.